- Home /
Question by
rajat · Jul 02, 2013 at 03:07 PM ·
gameobjectcolorrenderer
Dynamically fill color in a gameobject?
I need to fill color in a GameObject when somebody hovers over it. How should i go about filling the GameObject with different another color to change the color at once i would use,
Material newMaterial = new Material(Shader.Find("shadername"));
newMaterial.color = whateverColor;
gameObjectRenderer.material = newMaterial ;
but i can't figure out how to animate color filling.
Example of what i want:
Unhovered gameobject will look like
Then when somebody hovers over it, the color will start to fill and a event will be executed when the game-object is filled completely.
black_down_arrow.png
(1.7 kB)
black_down_arrow1.png
(36.4 kB)
Comment
Best Answer
Answer by robertbu · Jul 02, 2013 at 03:12 PM
Use three images. One just the arrow, one the arrow full, and a gradient. The technique is the same as used in this progress bar:
http://answers.unity3d.com/questions/14770/creating-a-circular-progressbar-timer.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613105336im_/https://answers.unity.com/themes/thub/images/avi.jpg)