Ejemplo n.º 1
0
        public void PushScreen <T>(bool isPopup) where T : GUIScreen
        {
            GUIScreen foundScreen = FoundScreen <T>();

            if (foundScreen != null)
            {
                PushScreen(foundScreen, isPopup);
            }
            else
            {
                Debug.LogWarning("Screen " + typeof(T) + " not found!");
            }
        }
Ejemplo n.º 2
0
        public void ShowScreen <T>(bool hideAll = false) where T : GUIScreen
        {
            GUIScreen foundScreen = FoundScreen <T>();

            if (foundScreen != null)
            {
                ShowScreen(foundScreen, hideAll);
            }
            else
            {
                Debug.LogWarning("Screen " + typeof(T) + " not found!");
            }
        }
Ejemplo n.º 3
0
        public void HideScreen <T>() where T : GUIScreen
        {
            GUIScreen foundScreen = FoundScreen <T>();

            if (foundScreen != null)
            {
                foundScreen.Hide();
                SortByLayer();
            }
            else
            {
                Debug.LogWarning("Screen " + typeof(T) + " not found!");
            }
        }
Ejemplo n.º 4
0
        public void ShowScreen(GUIScreen screen, bool hideAll = false)
        {
            if (hideAll)
            {
                foreach (var curScreen in screens)
                {
                    if (curScreen.GetType() != screen.GetType())
                    {
                        curScreen.Hide();
                    }
                }
                screenStack.Clear();
            }

            screen.Show();
            SortByLayer();
        }
Ejemplo n.º 5
0
        void Start()
        {
            Debug.Log("GuiController start");
            foreach (var curPrefab in screenPrefabs)
            {
                // Debug.Log("Screen " + curPrefab.name + " instantiated");
                GameObject curScreen = Instantiate(curPrefab);
                if (screensRoot != null)
                {
                    curScreen.transform.SetParent(screensRoot.transform, false);
                }
                else
                {
                    curScreen.transform.SetParent(this.gameObject.transform, false);
                }

                GUIScreen guiScreen = curScreen.GetComponent <GUIScreen>();
                screens.Add(guiScreen);
            }

            //GUIScreen showedScreen = null;
            List <Button> buttons = new List <Button>();

            foreach (GUIScreen screen in screens)
            {
                foreach (Button btn in screen.GetComponentsInChildren <Button>(true).ToList().Where(x => !screen.IgnoreForPlayClickSoundButtons.Contains(x)))
                {
                    buttons.Add(btn);
                }
            }

            foreach (var curScreen in screens)
            {
                curScreen.gameObject.SetActive(false);
            }

            foreach (var curScreen in currentScreens)
            {
                curScreen.Show();
            }

            buttons.ForEach(x => x.onClick.AddListener(OnButtonClick));
        }
Ejemplo n.º 6
0
        public void PopScreen()
        {
            if (screenStack.Count == 0)
            {
                return;
            }

            GUIScreen curScreen = screenStack.Pop();

            curScreen.Hide();

            if (screenStack.Count > 0)
            {
                GUIScreen newScreen = screenStack.Peek();
                newScreen.Show();
                //newScreen.transform.SetAsLastSibling();
            }

            SortByLayer();
        }
Ejemplo n.º 7
0
        public void PushScreen(GUIScreen screen, bool isPopup)
        {
            if (!isPopup)
            {
                foreach (var curScreen in screenStack)
                {
                    Debug.Log(curScreen.gameObject);
                    curScreen.Hide();
                }
            }

            //screen.transform.SetAsLastSibling();
            screen.Show();
            screenStack.Push(screen);

            int i = 0;

            foreach (var curScreen in screenStack)
            {
                curScreen.OffsetZ = i++;
            }

            SortByLayer();
        }