Exemplo n.º 1
0
        public void CloseUIView(BaseUIView closeUIView)
        {
            if (closeUIView == null)
            {
                return;
            }

            if (closeUIView.DeleteOnHide)
            {
                _allUIView.Remove(closeUIView.UIType);
                _backUIViewQueue.Remove(closeUIView);
                _openUIViewQueue.Remove(closeUIView);
                closeUIView.Hide();
                closeUIView.Release();
                GameObject.Destroy(closeUIView.gameObject);
            }
            else
            {
                ChangeUIViewParent(closeUIView, true);
                closeUIView.ChangeCameraRenderTexture(false);
                closeUIView.ChangeCanvasLayer(HideLayer);
                closeUIView.ChangeGraphicRaycasterState(false);
                _openUIViewQueue.Remove(closeUIView);
                closeUIView.Hide();
            }
        }
Exemplo n.º 2
0
        public void Release()
        {
            if (_allUIView == null)
            {
                return;
            }

            for (UI_TYPE i = UI_TYPE.UI_NONE; i < UI_TYPE.UI_MAX; ++i)
            {
                BaseUIView uiView = null;
                if (_allUIView.TryGetValue(i, out uiView))
                {
                    if (uiView != null)
                    {
                        if (!uiView.IsClose())
                        {
                            uiView.Hide();
                        }
                        uiView.Release();
                        GameObject.Destroy(uiView.gameObject);
                    }
                }
            }

            _UICamera = null;
            _allUIView.Clear();
            _backUIViewQueue.Clear();
            Resources.UnloadUnusedAssets();
        }
Exemplo n.º 3
0
        public void Update()
        {
            if (_allUIView == null || _allUIView.Count <= 0)
            {
                return;
            }

            float deltaTime = Time.deltaTime;

            for (UI_TYPE type = UI_TYPE.UI_NONE; type < UI_TYPE.UI_MAX; ++type)
            {
                BaseUIView baseUIView = null;
                if (_allUIView.TryGetValue(type, out baseUIView))
                {
                    baseUIView.Core(deltaTime);

                    if (baseUIView.IsNeedDestroy())
                    {
                        _allUIView.Remove(type);
                        _backUIViewQueue.Remove(baseUIView);
                        _openUIViewQueue.Remove(baseUIView);
                        baseUIView.Hide();
                        baseUIView.Release();
                        GameObject.Destroy(baseUIView.gameObject);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public BaseUIView OpenUIView(UI_TYPE uiType, object param = null)
        {
            BaseUIView baseUIView = null;

            if (!_allUIView.TryGetValue(uiType, out baseUIView))
            {
                string     uiAssetPath = GetUIAssetPathByUIType(uiType);
                GameObject goUI        = GameObject.Instantiate(Resources.Load <GameObject>(uiAssetPath));
                baseUIView = goUI.GetComponent <BaseUIView>();
                _allUIView.Add(uiType, baseUIView);
            }
            else
            {
                if (!baseUIView.IsClose())
                {
                    baseUIView.Hide();
                }
            }

            if (baseUIView.IsNeedBack())
            {
                for (int i = 0, len = _backUIViewQueue.Count; i < len; ++i)
                {
                    BaseUIView tempUIView = _backUIViewQueue[i];
                    if (tempUIView.Equals(baseUIView))
                    {
                        _backUIViewQueue.RemoveAt(i);
                        break;
                    }
                }

                _backUIViewQueue.Add(baseUIView);
            }

            if (_openUIViewQueue.Contains(baseUIView))
            {
                _openUIViewQueue.Remove(baseUIView);
            }
            _openUIViewQueue.Add(baseUIView);

            ChangeUIViewParent(baseUIView);

            HideOldView();
            baseUIView.UIType = uiType;
            if (baseUIView.IsShowAfterOpenEffect)
            {
                baseUIView.UIParam = param;
                baseUIView.ShowOpenEffect();
            }
            else
            {
                baseUIView.Show(param);
            }
            baseUIView.ChangeCameraRenderTexture(true);
            baseUIView.ChangeCanvasLayer(UILayer);
            baseUIView.ChangeGraphicRaycasterState(true);
            RefreshUISortingOrder();

            return(baseUIView);
        }