Example #1
0
    public void ChangePage(int index)
    {
        //SceneManager.LoadScene(index);
        int numScreens = gameObject.transform.childCount;

        if (index == 0)
        {
            Debug.Log("Quit");
            Application.Quit();
        }
        else
        {
            if (index == 4)
            {
                Debug.Log("Resetting CC");
                cc.ResetMenu();
            }
            if (index == 7)
            {
                Debug.Log("Resetting SM");
                sm.ResetMenu();
            }
            if (index == 2)
            {
                Debug.Log("Resetting LB");
                lb.CreateBoard();
            }
            if (index <= numScreens)
            {
                for (int x = 0; x < numScreens; x++)
                {
                    GameObject child = gameObject.transform.GetChild(x).gameObject;
                    if (x != index - 1)
                    {
                        if (x == 3 && cc.isReady)
                        {
                            cc.DestroyPlayers();
                        }
                        child.SetActive(false);
                        if (x == 1)
                        {
                            lb.ResetMenu();
                        }
                    }
                    else
                    {
                        if (x == 3 && cc.isReady)
                        {
                            cc.trigger = true;
                        }
                        child.SetActive(true);
                    }
                }
            }
            else
            {
                SceneManager.LoadScene(1);
            }
        }
    }