Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 15 buttons on my screen at onClick event am fetching the button and hiding that button using

EventSystem.current.currentSelectedGameObject.SetActive(false); 

now at the end i have to show buttons again so i am using

for (int i = 0; i < 15; i++)
 {
     tag1 = "Button" + (i + 1);
     GameObject.FindGameObjectWithTag(tag1).SetActive(true);
     Debug.Log("done");
 }

Loop is giving error becuase it is not able to find object which has been hidden or setActive(false) from other references unity forum i see same solution but i don't know why it is not working in my case

i know issue is with "FindGameObjectWithTag" function i will have to replace it with some other

any help will be appreciated
Thanks

share|improve this question
up vote 0 down vote accepted

You can try this.

// in void Start
objs = GameObject.FindGameObjectsWithTag (tag);

// void Update()
foreach (GameObject objs in obj) {
    obj.SetActive(true);
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.