Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: hurleybird on June 20, 2014, 02:15:22 AM
-
I want to change the color of a sprite from green to red based off a value between 1 and 100. Before I go about coding this, is there an easy way to do this in NGUI that I'm not aware of?
-
Look into tween color script
-
I don't think that will work, as tween color will change the sprite from one color to another over a specific duration when given a specific trigger. It's just a simple animation. I want to have the sprite be one color at value 1, another color at value 0, and slowly change from one to the other as that value goes from 1 to 0. That said, some of the code from tween color may be able to reused to help me create a new script with the functionality I need. Let me know if I'm mistaken or there's some other included script that functions the way I want it to though!
Edit:
I got the color changing script created, but how do I actually assign that color to a UI2DSprite element?
-
UI2DSprite is a widget.
GetComponent<UI2DSprite>().color = Color.red;
or just like any other widget:
GetComponent<UIWidget>().color = Color.red;
-
UI2DSprite is a widget.
GetComponent<UI2DSprite>().color = Color.red;
or just like any other widget:
GetComponent<UIWidget>().color = Color.red;
Thanks!