コード例 #1
0
 public void ShowExcludeChilds(System.Action callback = null, bool resetAnimation = true)
 {
     this.Show(AppearanceParameters.Default()
               .ReplaceCallback(callback: callback)
               .ReplaceResetAnimation(resetAnimation: resetAnimation)
               .ReplaceIncludeChilds(includeChilds: false));
 }
コード例 #2
0
        /*public string GetCustomTag(int custom) {
         *
         *      return string.Format("{0}_{1}", this.GetInstanceID(), custom);
         *
         * }*/

        #region Manual Events
        public void HideExcludeChilds(System.Action callback = null, bool immediately = false)
        {
            this.Hide(AppearanceParameters.Default()
                      .ReplaceCallback(callback: callback)
                      .ReplaceImmediately(immediately: immediately)
                      .ReplaceIncludeChilds(includeChilds: false));
        }
コード例 #3
0
 public void Hide()
 {
     this.Hide(AppearanceParameters.Default());
 }
コード例 #4
0
 public void Show()
 {
     this.Show(AppearanceParameters.Default());
 }
コード例 #5
0
 public void ShowHide(bool state)
 {
     this.ShowHide(state, AppearanceParameters.Default());
 }
コード例 #6
0
 public void Show(System.Action callback, bool resetAnimation)
 {
     this.Show(AppearanceParameters.Default()
               .ReplaceCallback(callback: callback)
               .ReplaceResetAnimation(resetAnimation: resetAnimation));
 }
コード例 #7
0
 public void Show(bool resetAnimation)
 {
     this.Show(AppearanceParameters.Default()
               .ReplaceResetAnimation(resetAnimation: resetAnimation));
 }
コード例 #8
0
        private IEnumerator Show_INTERNAL_YIELD(System.Action onShowEnd, AttachItem transitionItem)
        {
            while (this.paused == true)
            {
                yield return(false);
            }

            this.TurnOn();

            var parameters = AppearanceParameters.Default();

            var counter = 0;

            System.Action callback = () => {
                if (this.currentState != WindowObjectState.Showing)
                {
                    return;
                }

                ++counter;
                if (counter < 6)
                {
                    return;
                }

                                #if UNITY_EDITOR
                Profiler.BeginSample("WindowBase::OnShowEnd()");
                                #endif

                this.DoLayoutShowEnd(parameters);
                this.modules.DoShowEnd(parameters);
                this.audio.DoShowEnd(parameters);
                this.events.DoShowEnd(parameters);
                this.transition.DoShowEnd(parameters);
                this.DoShowEnd(parameters);
                if (onShowEnd != null)
                {
                    onShowEnd();
                }

                                #if UNITY_EDITOR
                Profiler.EndSample();
                                #endif

                this.currentState = WindowObjectState.Shown;
            };

            parameters = parameters.ReplaceCallback(callback);

                        #if UNITY_EDITOR
            Profiler.BeginSample("WindowBase::OnShowBegin()");
                        #endif

            this.DoLayoutShowBegin(parameters);

            this.modules.DoShowBegin(parameters);

            if (transitionItem != null && transitionItem.audioTransition != null)
            {
                this.audio.DoShowBegin(transitionItem.audioTransition, transitionItem.audioTransitionParameters, parameters);
            }
            else
            {
                this.audio.DoShowBegin(parameters);
            }

            this.events.DoShowBegin(parameters);

            if (transitionItem != null && transitionItem.transition != null)
            {
                this.transition.DoShowBegin(transitionItem.transition, transitionItem.transitionParameters, parameters);
            }
            else
            {
                this.transition.DoShowBegin(parameters);
            }

            this.DoShowBegin(parameters);

                        #if UNITY_EDITOR
            Profiler.EndSample();
                        #endif
        }
コード例 #9
0
 public void Hide(bool immediately)
 {
     this.Hide(AppearanceParameters.Default()
               .ReplaceImmediately(immediately: immediately));
 }
コード例 #10
0
 public void DoHideBegin(System.Action callback)
 {
     this.DoHideBegin(AppearanceParameters.Default().ReplaceCallback(callback: callback));
 }
コード例 #11
0
        /// <summary>
        /// Unregisters the sub component.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
        public void UnregisterSubComponent(WindowObjectElement subComponent, System.Action callback = null)
        {
#if UNITY_EDITOR
            if (Application.isPlaying == false)
            {
                return;
            }
#endif

            var sendCallback = true;

            //Debug.Log("UNREGISTER: " + subComponent + " :: " + this.GetComponentState() + "/" + subComponent.GetComponentState());

            this.subComponents.Remove(subComponent);

            switch (this.GetComponentState())
            {
            case WindowObjectState.Shown:

                // after OnShowEnd
                subComponent.DoHideBegin(AppearanceParameters.Default().ReplaceCallback(() => {
                    subComponent.DoHideEnd(AppearanceParameters.Default());
                    subComponent.DoDeinit();

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

                sendCallback = false;

                break;

            case WindowObjectState.Hiding:

                // after OnHideBegin
                subComponent.DoHideBegin(AppearanceParameters.Default());

                sendCallback = false;
                if (callback != null)
                {
                    callback();
                }

                break;

            case WindowObjectState.Hidden:

                // after OnHideEnd
                subComponent.DoHideBegin(AppearanceParameters.Default().ReplaceCallback(() => {
                    subComponent.DoHideEnd(AppearanceParameters.Default());
                    subComponent.DoDeinit();

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

                sendCallback = false;

                break;
            }

            if (sendCallback == true && callback != null)
            {
                callback();
            }
        }
コード例 #12
0
        /// <summary>
        /// Registers the sub component.
        /// If you want to instantiate a new component manualy but wants window events - register this component here.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
        public virtual void RegisterSubComponent(WindowObjectElement subComponent)
        {
            //Debug.Log("TRY REGISTER: " + subComponent + " :: " + this.GetComponentState() + "/" + subComponent.GetComponentState(), this);
            if (this.subComponents.Contains(subComponent) == false)
            {
                this.subComponents.Add(subComponent);
            }
            else
            {
                WindowSystemLogger.Warning(this, "RegisterSubComponent can't complete because of duplicate item.");
                return;
            }

            switch (this.GetComponentState())
            {
            case WindowObjectState.Hiding:

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.DoInit();
                }

                subComponent.SetComponentState(this.GetComponentState());

                break;

            case WindowObjectState.Hidden:

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.DoInit();
                }

                subComponent.SetComponentState(this.GetComponentState());

                break;

            case WindowObjectState.Initializing:
            case WindowObjectState.Initialized:

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.DoInit();
                }

                break;

            case WindowObjectState.Showing:

                // after OnShowBegin

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.DoInit();
                }

                if (subComponent.showOnStart == true)
                {
                    subComponent.DoShowBegin(AppearanceParameters.Default());
                }

                break;

            case WindowObjectState.Shown:

                // after OnShowEnd

                if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                {
                    subComponent.DoInit();
                }

                if (subComponent.showOnStart == true)
                {
                    subComponent.DoShowBegin(AppearanceParameters.Default().ReplaceCallback(() => {
                        subComponent.DoShowEnd(AppearanceParameters.Default());
                    }));
                }

                break;
            }

            if (this.GetWindow() != null)
            {
                subComponent.Setup(this.GetWindow());
                // subComponent.Setup(this.GetLayoutRoot());
            }
        }
コード例 #13
0
        private IEnumerator Hide_INTERNAL_YIELD(System.Action onHideEnd, AttachItem transitionItem)
        {
            while (this.paused == true)
            {
                yield return(false);
            }

            this.activeIteration = 0;
            this.SetInactive();

            if (this.preferences.sendActiveState == true)
            {
                WindowSystem.SendActiveStateByWindow(this);
            }

            var parameters = AppearanceParameters.Default();

            var counter = 0;

            System.Action callback = () => {
                if (this.currentState != WindowObjectState.Hiding)
                {
                    return;
                }

                ++counter;
                if (counter < 6)
                {
                    return;
                }

                WindowSystem.AddToHistory(this);

                                #if UNITY_EDITOR
                Profiler.BeginSample("WindowBase::OnHideEnd()");
                                #endif

                this.DoLayoutHideEnd(parameters);
                this.modules.DoHideEnd(parameters);
                this.audio.DoHideEnd(parameters);
                this.events.DoHideEnd(parameters);
                this.transition.DoHideEnd(parameters);
                this.DoHideEnd(parameters);
                if (onHideEnd != null)
                {
                    onHideEnd();
                }

                                #if UNITY_EDITOR
                Profiler.EndSample();
                                #endif

                this.currentState = WindowObjectState.Hidden;

                this.Recycle(setInactive: this.TurnOff());
            };

            parameters = parameters.ReplaceCallback(callback);

                        #if UNITY_EDITOR
            Profiler.BeginSample("WindowBase::OnHideBegin()");
                        #endif

            this.DoLayoutHideBegin(parameters);

            this.modules.DoHideBegin(parameters);

            if (transitionItem != null && transitionItem.audioTransition != null)
            {
                this.audio.DoHideBegin(transitionItem.audioTransition, transitionItem.audioTransitionParameters, parameters);
            }
            else
            {
                this.audio.DoHideBegin(parameters);
            }

            this.events.DoHideBegin(parameters);

            if (transitionItem != null && transitionItem.transition != null)
            {
                this.transition.DoHideBegin(transitionItem.transition, transitionItem.transitionParameters, parameters);
            }
            else
            {
                this.transition.DoHideBegin(parameters);
            }

            this.DoHideBegin(parameters);

                        #if UNITY_EDITOR
            Profiler.EndSample();
                        #endif
        }
コード例 #14
0
        /// <summary>
        /// Registers the sub component.
        /// If you want to instantiate a new component manualy but wants window events - register this component here.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
        public virtual void RegisterSubComponent(WindowObjectElement subComponent)
        {
            //Debug.Log("TRY REGISTER: " + subComponent + " :: " + this.GetComponentState() + "/" + subComponent.GetComponentState(), this);
            if (this.subComponents.Contains(subComponent) == false)
            {
                subComponent.rootComponent = this;
                this.subComponents.Add(subComponent);
            }
            else
            {
                WindowSystemLogger.Warning(this, "RegisterSubComponent can't complete because of duplicate item.");
                return;
            }

                        #if UNITY_EDITOR
            if (Application.isPlaying == false)
            {
                return;
            }
                        #endif

            var controller = (subComponent as IWindowEventsController);
            subComponent.DoLoad(async: false, onItem: null, callback: () => {
                switch (this.GetComponentState())
                {
                case WindowObjectState.Hiding:

                    if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                    {
                        controller.DoInit();
                        WindowSystem.RunSafe(subComponent.OnWindowActive);
                    }

                    subComponent.SetComponentState(this.GetComponentState());

                    break;

                case WindowObjectState.Hidden:

                    if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                    {
                        controller.DoInit();
                        WindowSystem.RunSafe(subComponent.OnWindowActive);
                    }

                    subComponent.SetComponentState(this.GetComponentState());

                    break;

                case WindowObjectState.Initializing:
                case WindowObjectState.Initialized:

                    if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                    {
                        controller.DoInit();
                        WindowSystem.RunSafe(subComponent.OnWindowActive);
                    }

                    break;

                case WindowObjectState.Showing:

                    // after OnShowBegin

                    if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                    {
                        controller.DoInit();
                        WindowSystem.RunSafe(subComponent.OnWindowActive);
                    }

                    if (subComponent.showOnStart == true)
                    {
                        controller.DoShowBegin(AppearanceParameters.Default());
                    }

                    break;

                case WindowObjectState.Shown:

                    // after OnShowEnd

                    if (subComponent.GetComponentState() == WindowObjectState.NotInitialized)
                    {
                        controller.DoInit();
                        WindowSystem.RunSafe(subComponent.OnWindowActive);
                    }

                    if (subComponent.showOnStart == true)
                    {
                        controller.DoShowBegin(AppearanceParameters.Default().ReplaceCallback(() => {
                            controller.DoShowEnd(AppearanceParameters.Default());
                        }));
                    }

                    break;
                }

                if (this.GetWindow() != null)
                {
                    subComponent.Setup(this.GetWindow());
                    // subComponent.Setup(this.GetLayoutRoot());
                }
            });
        }
コード例 #15
0
 public void Hide(System.Action callback, bool immediately)
 {
     this.Hide(AppearanceParameters.Default()
               .ReplaceCallback(callback: callback)
               .ReplaceImmediately(immediately: immediately));
 }
コード例 #16
0
        /// <summary>
        /// Unregisters the sub component.
        /// </summary>
        /// <param name="subComponent">Sub component.</param>
        public virtual void UnregisterSubComponent(WindowObjectElement subComponent, System.Action callback = null, bool immediately = true)
        {
                        #if UNITY_EDITOR
            if (Application.isPlaying == false)
            {
                return;
            }
                        #endif

            var sendCallback = true;

            //Debug.Log("UNREGISTER: " + subComponent + " :: " + this.GetComponentState() + "/" + subComponent.GetComponentState());

            subComponent.rootComponent = null;
            this.subComponents.Remove(subComponent);

            var controller = (subComponent as IWindowEventsController);

            switch (subComponent.GetComponentState())
            {
            case WindowObjectState.Showing:
            case WindowObjectState.Shown:

                // after OnShowEnd
                controller.DoWindowClose();
                controller.DoWindowInactive();
                controller.DoHideBegin(AppearanceParameters.Default().ReplaceForced(forced: true).ReplaceImmediately(immediately));
                controller.DoHideEnd(AppearanceParameters.Default().ReplaceForced(forced: true).ReplaceImmediately(immediately));
                controller.DoWindowUnload();
                controller.DoDeinit(() => { if (callback != null)
                                            {
                                                callback();
                                            }
                                    });

                sendCallback = false;

                break;

            case WindowObjectState.Hiding:

                // after OnHideBegin
                controller.DoWindowClose();
                controller.DoWindowInactive();
                controller.DoHideEnd(AppearanceParameters.Default().ReplaceForced(forced: true).ReplaceImmediately(immediately));
                controller.DoWindowUnload();
                controller.DoDeinit(() => { if (callback != null)
                                            {
                                                callback();
                                            }
                                    });

                sendCallback = false;

                break;

            case WindowObjectState.Hidden:

                // after OnHideEnd
                controller.DoWindowClose();
                controller.DoWindowInactive();
                controller.DoWindowUnload();
                controller.DoDeinit(() => { if (callback != null)
                                            {
                                                callback();
                                            }
                                    });

                sendCallback = false;

                break;
            }

            if (sendCallback == true && callback != null)
            {
                callback();
            }
        }
コード例 #17
0
        private IEnumerator Hide_INTERNAL_YIELD(System.Action onHideEnd, AttachItem transitionItem)
        {
            while (this.paused == true)
            {
                yield return(false);
            }

            var parameters = AppearanceParameters.Default();

            var counter = 0;

            System.Action callback = () => {
                if (this.currentState != WindowObjectState.Hiding)
                {
                    return;
                }

                ++counter;
                if (counter < 6)
                {
                    return;
                }

                WindowSystem.AddToHistory(this);

                this.Recycle();

                this.DoLayoutHideEnd(parameters);
                this.modules.DoHideEnd(parameters);
                this.audio.DoHideEnd(parameters);
                this.events.DoHideEnd(parameters);
                this.transition.DoHideEnd(parameters);
                this.DoHideEnd(parameters);
                if (onHideEnd != null)
                {
                    onHideEnd();
                }

                this.currentState = WindowObjectState.Hidden;

                if (this != null && this.gameObject != null)
                {
                    this.gameObject.SetActive(false);
                }
            };

            parameters = parameters.ReplaceCallback(callback);

            this.DoLayoutHideBegin(parameters);

            this.modules.DoHideBegin(parameters);

            if (transitionItem != null && transitionItem.audioTransition != null)
            {
                this.audio.DoHideBegin(transitionItem.audioTransition, transitionItem.audioTransitionParameters, parameters);
            }
            else
            {
                this.audio.DoHideBegin(parameters);
            }

            this.events.DoHideBegin(parameters);

            if (transitionItem != null && transitionItem.transition != null)
            {
                this.transition.DoHideBegin(transitionItem.transition, transitionItem.transitionParameters, parameters);
            }
            else
            {
                this.transition.DoHideBegin(parameters);
            }

            this.DoHideBegin(parameters);

            yield return(true);
        }