I have seven objects and buttons. I want to make sure that when I press the button, I see the object and if the button is not pressed, I don’t want to see the object. So, I set up the OnClick() event : Gameobject.SetActive. When i press play mode and button, object is not showing.
In the OnClick event, after choosing the SetActive function, did you click the checkbox that appeared? SetActive takes a bool argument–that is, you can say SetActive(true) to enable an object or SetActive(false) to disable it–so if the check box is NOT checked, you are turning it off rather than turning it on.
Yeah, I already checked.
When button 1 of the 7 buttons is pressed, object A is visible (button 1 is set to show only object A, the rest is not checked). Button 2 was set to show only object B, and previous object A and the rest were set to be invisible. Then when button 2 is pressed, nothing is visible(Object A is also invisible and object B is invisible).
If it worked for button 1 showing object A, but not for button 2 showing object B, then something is different between the two. Possibly an error in your button configuration, possibly a different in your object hierarchy, possibly a difference in the way the object draws itself.