Zagham Arshad Bajwa Zagham Arshad Bajwa - 1 year ago 363
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 Source
public Image myButtonImage; // Assign /Initilize from Editor or code
private Button level2;

void Start ()
    level2 = GameObject.Find ("level2").GetComponent<Button> ();
    level2.image = myButtonImage;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download