Example #1
0
        public static void HideAll(WindowBase except = null, System.Action callback = null)
        {
            WindowSystem.instance.currentWindows.RemoveAll((window) => window == null);

            var imax = WindowSystem.instance.currentWindows.Count;

            if (imax > 0)
            {
                WindowBase maxExcept   = null;
                var        maxDuration = 0f;
                foreach (var window in WindowSystem.instance.currentWindows)
                {
                    if (except == window)
                    {
                        continue;
                    }

                    var d = window.GetAnimationDuration(false);
                    if (d >= maxDuration)
                    {
                        maxDuration = d;
                        maxExcept   = window;
                    }
                }

                for (int i = 0; i < imax; ++i)
                {
                    if ((except == null || WindowSystem.instance.currentWindows[i] != except) &&
                        (maxExcept == null || WindowSystem.instance.currentWindows[i] != maxExcept))
                    {
                        WindowSystem.instance.currentWindows[i].Hide();
                    }
                }

                if (maxExcept != null)
                {
                    maxExcept.Hide(callback);
                }
                else
                {
                    if (callback != null)
                    {
                        callback();
                    }
                }
            }
            else
            {
                if (callback != null)
                {
                    callback();
                }
            }

            WindowSystem.ResetDepth();
        }
Example #2
0
            public void OnClick(WindowBase window)
            {
                var hideCur  = this.IsBackActionHide();
                var showPrev = this.IsBackActionShowPrevious();
                var showSpec = this.IsBackActionShowSpecific();

                if (window.GetState() == WindowObjectState.Shown || window.GetState() == WindowObjectState.Showing)
                {
                    this.onBackAction.Invoke();

                    if (hideCur == true || showPrev == true || showSpec == true)
                    {
                        if (showPrev == true)
                        {
                            var prev = WindowSystem.GetPreviousWindow(window);
                            if (prev != null)
                            {
                                prev.Show();
                            }
                            else
                            {
                                                                #if UNITY_EDITOR || DEBUGBUILD
                                Debug.LogWarning("Previous HistoryItem is null. Make sure your history was not cleared.");
                                                                #endif
                            }
                        }

                        if (hideCur == true)
                        {
                            window.Hide();
                        }

                        if (showSpec == true)
                        {
                            WindowSystem.Show(this.window);
                        }
                    }
                }
            }