Unity ITweenColor修改增加Graphic支持

itween原生不支持UGUI的組件顏色動畫,而項(xiàng)目中經(jīng)常會遇到這種需求,比如飄字淡入淡出~~巴拉巴拉 , 為了解決這個(gè)問題主要請參考這位大神的文章 http://www.cnblogs.com/YYRise/p/4432198.html,我在他的基礎(chǔ)上做了修改,主要是把image和rawImage整合成Graphic,因?yàn)閁GUI所有顯示組件都是繼承的Grapic類,這樣所有的UGUI組件都可以動態(tài)修改顏色了。一點(diǎn)微小的工作~~~詳細(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;
}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容