0
\$\begingroup\$

I am working on a game that contain 1000+ buttons starts from 0 - 999 with 3 decimals like 0-9, 00-99 and 000-999. if the user click the button the button image want to change. it working fine for me but the button with the name and Number(button name and button text both are same)50,100,200,300,400,...900 are not updating the ui. it showing an error like the object is destroyed but you are still trying to access it. but the button and the components in the buttons are not destroyed. i checked my code too.

        if (GameObject.Find (seatNo).GetComponent<UISetup> ()) {
            print ("Available");
        } else {
            print ("Not Available");
        }

here i tried to find the script is available or not. only for the buttons i mentioned above it's telling "Not Available". All others are working fine. but in the same time while running the game the script is available in the gameobject

screenshot for the button component screenshot for the button component 2

I am calling the method from another script like this

        UISetup button = GameObject.Find (seatNo).GetComponent<UISetup> ();
        button.changeBtnBG ();
        button.valueUpdates (chip);

in UISetup.cs i use this code to change the Image Source

public Sprite RedSelectedImg;
public Sprite GreenSelectedImg;

public void changeBtnBG(){
    print ("<-------------select img changed-------------->");
    if (redBtn == false) {
        this.GetComponent<Image>().sprite = GreenSelectedImg;
    } else {
        this.GetComponent<Image>().sprite = RedSelectedImg;
    }
}

I am using unity 5.6.0. i don't know what's the error. Anybody please help. Thanks in Advance

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

Here you are using to call the number by integer. you are using 3 types of numbers like 0,00 & 000. so the button number like 010 would be consider as 10, 020 would be consider as 20. etc., so only the picture of the button is not updating. declare 10 game objects for the problem buttons declare it. check the number and change image for the game object.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .