当美术给你的动画资源在unity 用代码不能播放或者播放效果不正确是很麻烦的,结果动画程序也做了。
今天改了个动画,发现透明度不正确,有可能是UGUI自身BUG。
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ColorWatcher : MonoBehaviour {
Color lastColor;
Image img;
#if UNITY_EDITOR
[MultilineAttribute(2)]
public string readMe = "动画改变Image.color时并不会生效,\n需要用这个脚本来触发color的setter";
#endif
void Start () {
img = GetComponent<Image>();
lastColor = img.color;
}
void LateUpdate () {
if (img.color != lastColor) {
lastColor = img.color;
img.color = new Color();
img.color = lastColor;
}
}
}
把这个脚本放到 动画修改过透明度的组件上面。