/// <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);

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

                // after OnShowEnd
                subComponent.DoWindowClose();
                subComponent.DoWindowInactive();
                subComponent.DoHideBegin(AppearanceParameters.Default().ReplaceForced(forced: true).ReplaceImmediately(immediately));
                subComponent.DoHideEnd(AppearanceParameters.Default().ReplaceForced(forced: true).ReplaceImmediately(immediately));
                subComponent.DoDeinit();

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

                break;

            case WindowObjectState.Hiding:

                // after OnHideBegin
                subComponent.DoWindowClose();
                subComponent.DoWindowInactive();
                subComponent.DoHideEnd(AppearanceParameters.Default().ReplaceForced(forced: true).ReplaceImmediately(immediately));
                subComponent.DoDeinit();

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

                break;

            case WindowObjectState.Hidden:

                // after OnHideEnd
                subComponent.DoWindowClose();
                subComponent.DoWindowInactive();
                subComponent.DoDeinit();

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

                break;
            }

            if (sendCallback == true && callback != null)
            {
                callback();
            }
        }
Example #2
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();
            }
        }