itween原生不支持UGUI的組件顏色動畫腋逆,而項目中經(jīng)常會遇到這種需求,比如飄字淡入淡出~~巴拉巴拉 健无, 為了解決這個問題主要請參考這位大神的文章 http://www.cnblogs.com/YYRise/p/4432198.html陶贼,我在他的基礎(chǔ)上做了修改春贸,主要是把image和rawImage整合成Graphic,因為UGUI所有顯示組件都是繼承的Grapic類嘹吨,這樣所有的UGUI組件都可以動態(tài)修改顏色了搬味。一點微小的工作~~~詳細(xì)的可以看那位大神的博客
ex修改位置:
//set tempColor and base fromColor:
if(target.GetComponent<GUITexture>()){
tempColor=fromColor=target.GetComponent<GUITexture>().color;
}else if(target.GetComponent<GUIText>()){
tempColor=fromColor=target.GetComponent<GUIText>().material.color;
}else if(target.GetComponent<Renderer>()){
tempColor=fromColor=target.GetComponent<Renderer>().material.color;
}else if(target.GetComponent<Light>()){
tempColor=fromColor=target.GetComponent<Light>().color;
}else if(target.GetComponent<UnityEngine.UI.Graphic>()){
tempColor=fromColor= target.GetComponent<UnityEngine.UI.Graphic>().color;
}
if(target.GetComponent<GUITexture>()){
target.GetComponent<GUITexture>().color=fromColor;
}else if(target.GetComponent<GUIText>()){
target.GetComponent<GUIText>().material.color=fromColor;
}else if(target.GetComponent<Renderer>()){
target.GetComponent<Renderer>().material.color=fromColor;
}else if(target.GetComponent<Light>()){
target.GetComponent<Light>().color=fromColor;
}else if(target.GetComponent<UnityEngine.UI.Graphic>()){
target.GetComponent<UnityEngine.UI.Graphic>().color=fromColor;
}