How do I access a button component

Hi all,

In my scene I have a few objects with buttons. I want to change the color of these buttons depending on the options the player chooses. How can I do this?

If you’re using the new UI system, you should get the button component of those buttons like this:

Button yourButton = yourObject.GetComponent<Button>();

Then you can access the color properties like this:

yourButton.colors.normalColor = newColor;

Here you can find all the variables you can change through colors property : http://docs.unity3d.com/ScriptReference/UI.ColorBlock.html

and don’t forget

using UnityEngine.UI;