Unity常用插件Dotween(四)
2017-06-28 21:55
399 查看
看demo场景时看漏了一个,其实这才是第三个场景。
这个场景叫做material,展示了对材质的操作。
先看看场景中操作的对象
![](https://oscdn.geek-share.com/Uploads/Images/Content/201706/ee2c9d642ae1853ab4dbb6d66cf10a3d)
没有albedo贴图,颜色是黑色(albedo控制物体表面的颜色,和透明度)。有emission贴图,颜色是白色(emission就是自发光效果)。
这个场景中的示例代码,演示了对材质,主颜色的操作,自发光颜色的操作,和贴图offset的操作
// NOTE: all tweens will be created in a paused state, so they can be toggled via the UI
// Store the material, since we will tween that
Material mat = target.GetComponent<Renderer>().material;
// COLOR
colorTween = mat.DOColor(toColor, 1).SetLoops(-1, LoopType.Yoyo).Pause();
// EMISSION
// Note that the float value you see in Unity's inspector, next to the emission's color,
// doesn't really exist in the shader (it's generated by Unity's inspector and applied to the material's color),
// se we have to tween the full _EmissionColor.
emissionTween = mat.DOColor(new Color(0, 0, 0, 0), "_EmissionColor", 1).SetLoops(-1, LoopType.Yoyo).Pause();
// OFFSET
// In this case we set the loop to Incremental and the ease to Linear, because it's cooler
offsetTween = mat.DOOffset(new Vector2(1, 1), 1).SetEase(Ease.Linear).SetLoops(-1, LoopType.Incremental).Pause();
创建tween时的.Pause()使tween创建后并不执行,而需要通过ui来执行和停止。
colorTween.TogglePause();
TogglePause可以切换动画的播放与暂停
这个场景叫做material,展示了对材质的操作。
先看看场景中操作的对象
没有albedo贴图,颜色是黑色(albedo控制物体表面的颜色,和透明度)。有emission贴图,颜色是白色(emission就是自发光效果)。
这个场景中的示例代码,演示了对材质,主颜色的操作,自发光颜色的操作,和贴图offset的操作
// NOTE: all tweens will be created in a paused state, so they can be toggled via the UI
// Store the material, since we will tween that
Material mat = target.GetComponent<Renderer>().material;
// COLOR
colorTween = mat.DOColor(toColor, 1).SetLoops(-1, LoopType.Yoyo).Pause();
// EMISSION
// Note that the float value you see in Unity's inspector, next to the emission's color,
// doesn't really exist in the shader (it's generated by Unity's inspector and applied to the material's color),
// se we have to tween the full _EmissionColor.
emissionTween = mat.DOColor(new Color(0, 0, 0, 0), "_EmissionColor", 1).SetLoops(-1, LoopType.Yoyo).Pause();
// OFFSET
// In this case we set the loop to Incremental and the ease to Linear, because it's cooler
offsetTween = mat.DOOffset(new Vector2(1, 1), 1).SetEase(Ease.Linear).SetLoops(-1, LoopType.Incremental).Pause();
创建tween时的.Pause()使tween创建后并不执行,而需要通过ui来执行和停止。
colorTween.TogglePause();
TogglePause可以切换动画的播放与暂停
相关文章推荐
- Unity常用插件之DoTween(一)
- Unity常用插件之DoTween(三)
- [Unity插件]DOTween基础
- unity 常用网站、插件、技术记录
- 制作Unity插件之-常用GUI绘制组建
- unity Dotween插件的简单介绍及示例代码
- 【DoTween】Unity插件DOTween教程(零)基础篇
- Unity 常用插件
- Unity插件学习——DOTween(一)
- 【DoTween】Unity插件DOTween教程(二)
- 【DoTween】Unity插件DOTween教程(一)
- 【狂云歌之unity_vr】开发unity插件——一次搞定unity编辑器常用功能
- unity Dotween插件的简单介绍及示例代码
- Unity插件DOTween教程
- Unity插件 DOTween基础
- [置顶] Unity 3D - 常用插件汇总
- Unity常用插件
- Unity插件_____DoTween(二)
- [Unity插件]DOTween基础
- 【DoTween】Unity插件DOTween教程(三)