- Home /
Change color of all instance of a material
Hello,
I have different UI elements, and I would like them to change color over time (all together and same color)
I give them a custom material but I have no many idea on how to proceed.
What is the best way to change the color of all instanced item that use a material ?
Answer by waterlight_ · Jun 28, 2018 at 09:24 AM
GetComponent<Renderer>().material.color
can be used to change the color of a material.
You could also change the color of UI elements using their class in UnityEngine.UI. Every UI element has a way to change its color value using code.
Your answer
![](https://koobas.hobune.stream/wayback/20220612165627im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Color problem with Unity 5 1 Answer
Changing material color from dictionary (C#) 0 Answers
Unity 2019.3.2f1 Unity Skybox Color Tint No Effect 0 Answers
Why when I create a new material with an img does it change the colours? 1 Answer
Unity3D -Trying to decrease color values when it equals to zero and curious result 0 Answers