Example #1
0
        private void Awake()
        {
            if (sceneRecorder == null)
            {
                var go = new GameObject("SceneRecorder");
                sceneRecorder = go.AddComponent <SceneRecorder>();
                DontDestroyOnLoad(go);
                foreach (var item in Buttons)
                {
                    if (item.gameObject.name == "SparseSpatialMap")
                    {
                        sceneRecorder.Record(item, this);
                    }
                }
            }
            else
            {
                sceneRecorder.Recover(this);
            }

            foreach (var item in Buttons)
            {
                item.onClick.AddListener(() =>
                {
                    sceneRecorder.Record(item, this);
                });
            }
        }
Example #2
0
        private void Start()
        {
            if (sceneRecorder == null)
            {
                var go = new GameObject("SceneRecorder");
                sceneRecorder = go.AddComponent <SceneRecorder>();
                DontDestroyOnLoad(go);
                foreach (var item in Buttons)
                {
                    if (item.gameObject.name == "SparseSpatialMap")
                    {
                        sceneRecorder.Record(item, this);
                    }
                }
            }
            else
            {
                sceneRecorder.Recover(this);
            }

            foreach (var item in Buttons)
            {
                item.onClick.AddListener(() =>
                {
                    sceneRecorder.Record(item, this);
                });
            }

            for (var i = 0; i < RightRoot.transform.childCount; ++i)
            {
                int count   = 0;
                var catgory = RightRoot.transform.GetChild(i).gameObject;
                for (var j = 0; j < catgory.transform.childCount; ++j)
                {
                    var sample = catgory.transform.GetChild(j).gameObject;
                    if (Application.CanStreamedLevelBeLoaded(sample.name))
                    {
                        var button = sample.GetComponent <Button>();
                        button.onClick.AddListener(() =>
                        {
                            UnityEngine.SceneManagement.SceneManager.LoadScene(sample.name);
                        });
                    }
                    else
                    {
                        sample.SetActive(false);
                        count++;
                    }
                }
                if (count == catgory.transform.childCount)
                {
                    Buttons[i].gameObject.SetActive(false);
                }
            }
        }