P
P
ProgramDevel2020-07-07 14:22:44
Unity
ProgramDevel, 2020-07-07 14:22:44

How to change the color of an object?

When you click on the button, you need to change the color of another object!
Not the button itself, but the color of another object
Thanks to whoever answers!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zZaKko, 2020-07-07
@ProgramDevel

Throw a prefab on another object. Then look where in another object the color is located (in which component), often it is SpriteRenderer or Image. And with the help of GetComponent you change the color.

obj.GetComponent<Image>().color = Color.Green
//Или любой другой из палитры цвет:
obj.GetComponent<Image>().color = new Color32(r,g,b,a);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question