Exemple #1
0
        public UIPanel ShowGamePlayScreen(string screenName, bool visible)
        {
            UIPanelInstance panelInstance = GetPanelInstance(screenName);

            if (panelInstance == null)
            {
                UIPanelInfo panelInfo = GetPanelReference(screenName);
                if (panelInfo == null)
                {
                    QLogger.LogErrorAndThrowException("No screen found with name:" + screenName);
                }
                if (panelInfo.type != UIPanelInfo.Type.GamePlay)
                {
                    QLogger.LogErrorAndThrowException("This panel is not a screen type");
                }
                panelInstance = CreatePanelInstanceAndAddToListIfNess(panelInfo);
                if (panelInstance == null)
                {
                    QLogger.LogErrorAndThrowException("Panel instance was not created!");
                }
            }
            if (!(panelInstance is GamePlayScreenPanelInstance))
            {
                QLogger.LogErrorAndThrowException("This panel is not screen type - 2");
            }
            GamePlayScreenPanelInstance screenInstance = panelInstance as GamePlayScreenPanelInstance;

            if (!gamePlayScreenPanels.Contains(screenInstance))
            {
                gamePlayScreenPanels.Add(screenInstance);
            }

            panelInstance.instance.SetActive(visible);
            return(panelInstance.uiPanel);
        }
Exemple #2
0
        public UIPanelInstance CreatePanelInstanceAndAddToListIfNess(UIPanelInfo panel)
        {
            if (GetPanelInstance(panel.panelName) != null)
            {
                return(GetPanelInstance(panel.panelName));
            }

            if (panel.uiObjectReference == null)
            {
                panel.uiObjectReference = ResourceManager.Instance.LoadAsset <UnityEngine.Object>(panel.objectPath);
            }

            if (panel.uiObjectReference == null)
            {
                QLogger.LogErrorAndThrowException("Panel object not found!");
            }

            GameObject instance = GameObject.Instantiate(panel.uiObjectReference, new Vector3(9999, 9999, 9999), Quaternion.identity, transform) as GameObject;

            instance.SetActive(false);
            instance.transform.localPosition = panel.localPosition;
            UIPanelInstance panelInstance = null;

            if (panel.type == UIPanelInfo.Type.Screen)
            {
                panelInstance = new ScreenPanelInstance();
            }
            else if (panel.type == UIPanelInfo.Type.Popup)
            {
                panelInstance = new PopupPanelInstance();
            }
            else if (panel.type == UIPanelInfo.Type.Alert)
            {
                panelInstance = new AlertPanelInstance();
            }
            else if (panel.type == UIPanelInfo.Type.GamePlay)
            {
                panelInstance = new GamePlayScreenPanelInstance();
            }
            else
            {
                QLogger.LogErrorAndThrowException("Should not be here !");
            }

            panelInstance.panelInfo = panel;
            panelInstance.instance  = instance;
            panelInstance.uiPanel   = instance.GetComponent <UIPanel>();
            if (panelInstance.uiPanel == null)
            {
                QLogger.LogErrorAndThrowException("Ui panel instance not found ");
            }
            panelsInMemory.Add(panelInstance);
            return(panelInstance);
        }
Exemple #3
0
        public void CloseUiPanelAndRemoveFromListIfNess(UIPanelInstance instance)
        {
            if (instance == null)
            {
                QLogger.LogErrorAndThrowException("panel instance is null"); return;
            }

            if (instance.panelInfo.keepInMemory)
            {
                instance.uiPanel.Reset();
                instance.instance.SetActive(false);
            }
            else
            {
                GameObject.Destroy(instance.instance);
                panelsInMemory.Remove(instance);
            }
        }
Exemple #4
0
        public UIPanel PushScreen(string screenName, bool visible)
        {
            UIPanelInstance panelInstance = GetPanelInstance(screenName);

            if (panelInstance == null)
            {
                UIPanelInfo panelInfo = GetPanelReference(screenName);
                if (panelInfo == null)
                {
                    QLogger.LogErrorAndThrowException("No screen found with name:" + screenName);
                }
                if (panelInfo.type != UIPanelInfo.Type.Screen)
                {
                    QLogger.LogErrorAndThrowException("This panel is not a screen type");
                }
                panelInstance = CreatePanelInstanceAndAddToListIfNess(panelInfo);
                if (panelInstance == null)
                {
                    QLogger.LogErrorAndThrowException("Panel instance was not created!");
                }
            }
            if (!(panelInstance is ScreenPanelInstance))
            {
                QLogger.LogErrorAndThrowException("This panel is not screen type - 2");
            }
            ScreenPanelInstance screenInstance = panelInstance as ScreenPanelInstance;

            if (screenPanelStack.Count > 0)
            {
                screenPanelStack.Peek().uiPanel.OnPusedBack();
                screenPanelStack.Peek().instance.SetActive(false);
            }
            screenPanelStack.Push(screenInstance);
            panelInstance.instance.SetActive(visible);
            return(panelInstance.uiPanel);
        }