Пример #1
0
        /// 显示
        public void Appear(UIFormHideFlag hideFlag = UIFormHideFlag.HideByCustom, bool dispatchdEvent = true)
        {
            //始终保持可见的Form,直接return
            if (IsAlwaysKeepVisible)
            {
                return;
            }
            //Remove Flag
            _hideFlags &= ~((int)hideFlag);
            //隐藏标志不为0或没有被隐藏,不能进行恢复操作
            if (_hideFlags != 0 || !_isHided)
            {
                return;
            }
            _isHided = false;
            if (_canvas != null)
            {
                _canvas.enabled      = true;
                _canvas.sortingOrder = _sortingOrder;
            }
            if (_graphicRaycaster && !IsDisableInput)
            {
                _graphicRaycaster.enabled = true;
            }
            //派发RevertVisible事件
            DispatchFormEvent(UIFormEventType.RevertToVisible);
            //派发VisibleChanged事件
            if (dispatchdEvent)
            {
                DispatchFormEvent(UIFormEventType.VisibleChanged);
            }

            //通知组件
            if (_uiComponents != null)
            {
                for (int i = 0; i < _uiComponents.Count; i++)
                {
                    _uiComponents[i].OnAppear();
                }
            }
        }
Пример #2
0
        /// 隐藏
        public void Hide(UIFormHideFlag hideFlag = UIFormHideFlag.HideByCustom, bool dispatchEvent = true)
        {
            //始终保持可见的Form,不能被隐藏
            if (IsAlwaysKeepVisible)
            {
                return;
            }
            //Add flag
            _hideFlags |= (int)hideFlag;
            //隐藏标志为0或者已经被隐藏,不能再次进行隐藏操作
            if (_hideFlags == 0 || _isHided)
            {
                return;
            }
            _isHided = true;

            if (_canvas != null)
            {
                _canvas.enabled = false;
            }
            if (_graphicRaycaster != null)
            {
                _graphicRaycaster.enabled = false;
            }
            if (dispatchEvent)
            {
                DispatchFormEvent(UIFormEventType.VisibleChanged);
            }
            //通知组件
            if (_uiComponents != null)
            {
                for (int i = 0; i < _uiComponents.Count; i++)
                {
                    _uiComponents[i].OnHide();
                }
            }
        }