Zagham Arshad Bajwa Zagham Arshad Bajwa - 2 months ago 33
C# Question

Unity 5.0 : how can change unity ui button image

i want to change image of Ui.Button in unity via script i am very new to unity development

i have a button i am accesing like this

level2 is my button in Ui



level2 = GameObject.Find ("level2").GetComponent<Button> ();





any help?

Answer
public Image myButtonImage; // Assign /Initilize from Editor or code
private Button level2;

void Start ()
{
    level2 = GameObject.Find ("level2").GetComponent<Button> ();
    level2.image = myButtonImage;
}
Comments