Example #1
0
        public BaseUI ShowUI(string UIName)
        {
            Transform outUIWnd = null;

            //如果已经打开了 则只需要显示在前面就行了
            if (_CurShowUI.TryGetValue(UIName, out outUIWnd))
            {
                outUIWnd.gameObject.SetActive(true);
                outUIWnd.SetAsLastSibling();
                return(outUIWnd.GetComponent <BaseUI>());
            }
            BaseUI UIScr = null;

            //没有打开 重新加载
            GameObject uiGameObj = LoadUI(UIName);

            if (uiGameObj == null)
            {
                return(null);
            }

            //检查脚本有没有加
            UIScr = uiGameObj.GetComponent <BaseUI>();
            if (UIScr == null)
            {
                Debug.Log("UI NotAddScript");
                return(null);
            }
            HideCurMutex();

            switch (UIScr.Type)
            {
            case UIType.Low:
                uiGameObj.transform.SetParent(_LowQue, false);
                break;

            case UIType.Normal:
                uiGameObj.transform.SetParent(_NormQue, false);
                //_BG.gameObject.active = true;
                break;
            }

            //ShowOPForUI(UIScr);
            _CurShowUI.Add(UIName, uiGameObj.transform);
            _GCUIDict.Remove(UIName);

            return(UIScr);
        }
Example #2
0
        //互斥窗口处理 隐藏当前已经打开的窗口
        public void HideCurMutex()
        {
            //没有打开后需要隐藏的窗口
            if (_NormQue.childCount < 1)
            {
                return;
            }
            //获取之前最后一个窗口
            BaseUI ShowingWnd = GetCurUI();

            //对上一个已打开窗口处理 若互斥则隐藏
            if (ShowingWnd != null && ShowingWnd.Type == UIType.Mutex)
            {
                ShowingWnd.Hide();
            }
        }
Example #3
0
        //关掉窗口后 处理上一个窗口 若隐藏则打开
        public void ReShowUI()
        {
            if (_NormQue.childCount < 1)
            {
                return;
            }
            BaseUI ShowingWnd = GetCurUI();

            if (ShowingWnd == null || ShowingWnd.Type != UIType.Mutex)
            {
                return;
            }
            else
            {
                ShowOPForUI(ShowingWnd);
            }
        }
Example #4
0
        private IEnumerator <int> AsyncLoadData()
        {
            UIInfoData _uiInfoData = null;

            UnityEngine.Object _uiprefab = null;
            GameObject         _uiObject = null;

            if (stackOpenUIs != null && stackOpenUIs.Count > 0)
            {
                do
                {
                    _uiInfoData = stackOpenUIs.Pop();
                    _uiprefab   = Resources.Load(_uiInfoData.Path);
                    if (_uiprefab != null)
                    {
                        _uiObject = MonoBehaviour.Instantiate(_uiprefab) as GameObject;

                        if (_uiObject == null)
                        {
                            yield break;
                        }
                        RectTransform rt      = _uiObject.GetComponent <RectTransform>();
                        BaseUI        _baseui = _uiObject.GetComponent <BaseUI>();
                        if (_baseui != null)
                        {
                            _baseui.SetUIWhenOpening(_uiInfoData.UIparams);
                        }
                        else
                        {
                            _baseui = _uiObject.AddComponent(_uiInfoData.ScriptType) as BaseUI;
                        }
                        Transform layer = uiContainer.FindChild(_baseui.GetUILayer().ToString());
                        rt.SetParent(layer, false);
                        dicOpenUIs.Add(_uiInfoData.UIType, _uiObject);
                    }
                    else
                    {
                        Debug.Log(" 当前路径不存在  " + _uiInfoData.Path);
                    }
                } while (stackOpenUIs.Count > 0);
            }

            yield return(0);
        }
Example #5
0
        //关闭窗口操作
        public void CloseWnd(BaseUI baseUI)
        {
            //_GCUIDict.Add(baseUI.UIName,Time.time);
            switch (baseUI.Type)
            {
            case UIType.Mutex:
                ReShowUI();
                break;

            case UIType.Low:
                return;

                break;
            }

            if (GetCurUI() != null)
            {
                _BG.gameObject.SetActive(false);
            }
        }
Example #6
0
 private void CloseUI(UIType _uiType, GameObject _uiObj)
 {
     if (_uiObj == null)
     {
         dicOpenUIs.Remove(_uiType);
     }
     else
     {
         BaseUI _baseUI = _uiObj.GetComponent <BaseUI>();
         if (_baseUI != null)
         {
             _baseUI.Release();
         }
         else
         {
             GameObject.Destroy(_uiObj);
             dicOpenUIs.Remove(_uiType);
         }
     }
 }
Example #7
0
 public void CloseUI(EnumUIType _uiType, GameObject _uiObj)
 {
     if (_uiObj == null)
     {
         dicOpenUIs.Remove(_uiType);
     }
     else
     {
         BaseUI _baseUI = _uiObj.GetComponent <BaseUI>();
         if (_baseUI == null)
         {
             GameObject.Destroy(_uiObj);
             dicOpenUIs.Remove(_uiType);
         }
         else
         {
             _baseUI.StateChanged += CloseUIHandle;
             _baseUI.Release();
         }
     }
 }
Example #8
0
        private IEnumerator <int> AsyncLoadData()
        {
            UIInfoData _uiInfoData = null;

            UnityEngine.Object _prefabObj = null;
            GameObject         _uiObject  = null;

            if (stackOpenUIs != null && stackOpenUIs.Count > 0)
            {
                do
                {
                    _uiInfoData = stackOpenUIs.Pop();
                    if (dicOpenUIsCache.ContainsKey(_uiInfoData.UIType))
                    {
                        dicOpenUIsCache[_uiInfoData.UIType].SetActive(true);
                        dicOpenUIs.Add(_uiInfoData.UIType, _uiObject);
                        break;
                    }
                    _prefabObj = Resources.Load(_uiInfoData.Path);
                    if (_prefabObj != null)
                    {
                        _uiObject = MonoBehaviour.Instantiate(_prefabObj, canvas.transform) as GameObject;
                        dicOpenUIsCache.Add(_uiInfoData.UIType, _uiObject);
                        BaseUI _baseUI = _uiObject.GetComponent <BaseUI>();
                        if (null == _baseUI)
                        {
                            _baseUI = _uiObject.AddComponent(_uiInfoData.ScriptType) as BaseUI;
                        }
                        if (null != _baseUI)
                        {
                            _baseUI.SetUIWhenOpening(_uiInfoData.UIParams);
                        }
                        dicOpenUIs.Add(_uiInfoData.UIType, _uiObject);
                    }
                } while (stackOpenUIs.Count > 0);
            }
            yield return(0);
        }