GameObject.Find ("Something") cannot find any disabled game object, so you cannot use this method. You can try adding a reflection to your button code:
public GameObject pannel1 = null; public GameObject pannel2 = null;
and set them to the right pane in the scene editor window.
Another way: first you need to keep both of your panels active in your scene, and then add the code to your script button as follows:
private GameObject panel1 = null; private GameObject panel2 = null; void Start() { panel1 = GameObject.Find("Panel1"); panel2 = GameObject.Find("Panel2"); } void OnClick() { panel2.SetActiveRecursively(true); panel1.SetActiveRecursively(false); }
The GameObject.Find (line name) function is not very efficient in Unity3D, so do not try to use it in Update () or every time you click a button.
source share