Exemplo n.º 1
0
        public void CloseTopUI()
        {
            if (mCurrentDialog)
            {
                mCurrentDialog.gameObject.SetActive(false);
                mCurrentDialog = null;

                mDialogs.Peek();
            }
        }
Exemplo n.º 2
0
        public void CloseAllUI()
        {
            if (mCurrentDialog)
            {
                mCurrentDialog.gameObject.SetActive(false);
                mCurrentDialog = null;
            }

            foreach (var item in mAllUIs.ToList())
            {
                item.Value.SetActive(false);
            }

            mDialogs.Clear();
        }
Exemplo n.º 3
0
        public T ShowUI <T>(bool bCloseLastOne = true, bool bPushHistory = true, NFDataList varList = null) where T : NFUIDialog
        {
            /*
             * if (mCurrentDialog != null && bCloseLastOne)
             * {
             *  Debug.Log("close ui " + mCurrentDialog.gameObject.name);
             *
             *  mCurrentDialog.gameObject.SetActive(false);
             *  mCurrentDialog = null;
             * }
             */

            string     name = typeof(T).ToString();
            GameObject uiObject;

            if (!mAllUIs.TryGetValue(name, out uiObject))
            {
                GameObject perfb = Resources.Load <GameObject>("UI/" + name);
                if (Application.platform == RuntimePlatform.Android ||
                    Application.platform == RuntimePlatform.IPhonePlayer ||
                    Application.platform == RuntimePlatform.OSXEditor ||
                    Application.platform == RuntimePlatform.WindowsEditor ||
                    Application.platform == RuntimePlatform.LinuxEditor)
                {
                    //perfb = Resources.Load<GameObject>("UI/" + name);
                }
                else
                {
                    //perfb = Resources.Load<GameObject>("UI/PC/" + name);
                }

                Debug.Log(name);

                uiObject      = GameObject.Instantiate(perfb);
                uiObject.name = name;

                uiObject.transform.SetParent(NFRoot.Instance().transform);

                mAllUIs.Add(name, uiObject);

                T panel = uiObject.GetComponent <T>();
                panel.Init();
            }
            else
            {
                uiObject.SetActive(true);

                //Debug.Log("open ui " + uiObject.gameObject.name);
            }

            if (uiObject)
            {
                T panel = uiObject.GetComponent <T>();
                if (varList != null)
                {
                    panel.mUserData = varList;
                }

                mCurrentDialog = panel;

                uiObject.SetActive(true);

                //Debug.Log("open ui " + uiObject.gameObject.name);

                if (bPushHistory)
                {
                    mDialogs.Enqueue(panel);
                }

                return(panel);
            }

            return(null);
        }