コード例 #1
0
        IEnumerator AsyncExit(NoArgDelegate callback = null)
        {
            AnimateExit();
            yield return(new WaitForSeconds(_exitDuration));

            if (callback != null)
            {
                callback.Invoke();
            }
        }
コード例 #2
0
        public void CloseTopMenu(bool animate = true, NoArgDelegate callback = null)
        {
            var topMenu = menuStack.Pop();

            void CloseTopMenuHelper()
            {
                if (topMenu.DestroyWhenClosed)
                {
                    Destroy(topMenu.gameObject);
                }
                else
                {
                    topMenu.gameObject.SetActive(false);
                }

                // Reactivate the top menu.
                // If a reactivated menu is an overlay we need to activate the menu under it.
                foreach (var menu in menuStack)
                {
                    menu.gameObject.SetActive(true);

                    if (menu.DisableMenusUnderneath)
                    {
                        break;
                    }
                }

                if (callback != null)
                {
                    callback.Invoke();
                }
            }

            if (topMenu._animatedElementOverlay && animate)
            {
                topMenu._animatedElementOverlay.Exit(CloseTopMenuHelper);
            }
            else
            {
                CloseTopMenuHelper();
            }
        }
コード例 #3
0
        IEnumerator Exit(float duration, float delay, NoArgDelegate callback = null)
        {
            if (_rectTransformAnimator == null || _textAnimator == null)
            {
                yield break;
            }

            yield return(new WaitForSeconds(delay));

            _rectTransformAnimator.ChangeAnchoredPosition3D(_animatedElementSettings._exitTo, duration);
            _textAnimator.ChangeAlpha(_animatedElementSettings._exitToAlpha, duration);
            yield return(new WaitForSeconds(duration));

            _animation = null;

            if (callback != null)
            {
                callback.Invoke();
            }
        }
コード例 #4
0
        public void OpenMenu(Menu menu, bool animate = true, NoArgDelegate callback = null)
        {
            if (menuStack.Count > 0 && menuStack.Peek() == menu)
            {
                return;
            }

            // Deactivate top menu.
            if (menuStack.Count > 0)
            {
                if (menu.DisableMenusUnderneath)
                {
                    foreach (var m in menuStack)
                    {
                        m.gameObject.SetActive(false);

                        if (m.DisableMenusUnderneath)
                        {
                            break;
                        }
                    }
                }

                var topCanvas      = menu.GetComponent <Canvas>();
                var previousCanvas = menuStack.Peek().GetComponent <Canvas>();
                topCanvas.sortingOrder = previousCanvas.sortingOrder + 1;
            }

            menuStack.Push(menu);

            if (menu._animatedElementOverlay)
            {
                menu._animatedElementOverlay.Enter(callback);
            }
            else
            {
                callback.Invoke();
            }
        }
コード例 #5
0
ファイル: Menu.cs プロジェクト: huabrandon0/unity-bh-ui
        protected static bool Close(bool animate = true, NoArgDelegate callback = null)
        {
            if (Instance == null)
            {
                //Debug.LogErrorFormat("Trying to close menu {0} but Instance is null", typeof(T));
                return(false);
            }
            else if (IsClosing)
            {
                return(true);
            }

            IsClosing = true;
            return(MenuManager.Instance.CloseMenu(Instance, animate, () =>
            {
                IsClosing = false;
                if (callback != null)
                {
                    callback.Invoke();
                }
            }));
        }
コード例 #6
0
ファイル: UIButton.cs プロジェクト: huabrandon0/unity-bh-ui
        IEnumerator Enter(float duration, float delay, NoArgDelegate callback = null)
        {
            if (_buttonRectTransformAnimator == null || _buttonImageAnimator == null || _buttonTextAnimator == null)
            {
                yield break;
            }

            _buttonRectTransformAnimator.SetAnchoredPosition3D(_animatedElementSettings._enterFrom);
            _buttonImageAnimator.SetAlpha(_animatedElementSettings._enterFromAlpha);
            _buttonTextAnimator.SetAlpha(_animatedElementSettings._enterFromAlpha);
            yield return(new WaitForSeconds(delay));

            _buttonRectTransformAnimator.ChangeAnchoredPosition3D(_animatedElementSettings._enterTo, duration);
            _buttonImageAnimator.ChangeAlpha(Mathf.Min(_animatedElementSettings._enterToAlpha, _buttonImageSettings._idleColor.a), duration);
            _buttonTextAnimator.ChangeAlpha(Mathf.Min(_animatedElementSettings._enterToAlpha, _buttonTextSettings._idleColor.a), duration);
            yield return(new WaitForSeconds(duration));

            _animation = null;

            if (callback != null)
            {
                callback.Invoke();
            }
        }