Exemplo n.º 1
0
    private IEnumerator AnimateGraphic_HIDE()
    {
        if (withDelay)
        {
            yield return(new WaitForSeconds(hideDelay));
        }

        for (int i = 1; i < GraphicAnimationRecords_HIDE.Count; i++)
        {
            if (GraphicAnimationRecords_HIDE[i - 1].Delay > 0)
            {
                yield return(new WaitForSeconds(GraphicAnimationRecords_HIDE[i - 1].Delay));
            }

            float startTime = Time.time;
            while (Time.time <= startTime + GraphicAnimationRecords_HIDE[i - 1].Duration)
            {
                float t = (Time.time - startTime) / GraphicAnimationRecords_HIDE[i - 1].Duration;

                if (graphicType == GraphicType.Image)
                {
                    Image img = graphic as Image;
                    img.sprite = GraphicAnimationRecords_HIDE[i - 1].Sprite;
                    img.color  = Color.Lerp(GraphicAnimationRecords_HIDE[i - 1].Color, GraphicAnimationRecords_HIDE[i].Color, t);
                }

                else if (graphicType == GraphicType.Text)
                {
                    Text txt = graphic as Text;
                    txt.text  = GraphicAnimationRecords_HIDE[i - 1].Text;
                    txt.color = Color.Lerp(GraphicAnimationRecords_HIDE[i - 1].Color, GraphicAnimationRecords_HIDE[i].Color, t);
                }

                yield return(null);
            }

            #region Set Final Values

            if (graphicType == GraphicType.Image)
            {
                Image img = graphic as Image;
                img.color = GraphicAnimationRecords_HIDE[i].Color;
            }
            else if (graphicType == GraphicType.Text)
            {
                Text txt = graphic as Text;
                txt.color = GraphicAnimationRecords_HIDE[i].Color;
            }

            #endregion
        }

        gameObject.SetActive(false);

        if (OnHideComplete != null)
        {
            OnHideComplete.Invoke();
        }
    }
    //==========================================================================================
    //==========================================================================================

    #region Hide Coroutines

    private IEnumerator AnimateTransform_HIDE()
    {
        if (withDelay)
        {
            yield return(new WaitForSeconds(hideDelay));
        }

        for (int i = 1; i < TransformAnimationRecords_HIDE.Count; i++)
        {
            if (TransformAnimationRecords_HIDE[i - 1].Delay > 0)
            {
                yield return(new WaitForSeconds(TransformAnimationRecords_HIDE[i - 1].Delay));
            }

            float startTime = Time.time;
            while (Time.time <= TransformAnimationRecords_HIDE[i - 1].Duration + startTime)
            {
                float t = (Time.time - startTime) / TransformAnimationRecords_HIDE[i - 1].Duration;

                rectTransform.anchoredPosition = Vector3.Lerp(TransformAnimationRecords_HIDE[i - 1].Position, TransformAnimationRecords_HIDE[i].Position, t);
                rectTransform.localScale       = Vector3.Lerp(TransformAnimationRecords_HIDE[i - 1].Scale, TransformAnimationRecords_HIDE[i].Scale, t);
                rectTransform.rotation         = Quaternion.Euler(Vector3.Lerp(TransformAnimationRecords_HIDE[i - 1].RotationEuler, TransformAnimationRecords_HIDE[i].RotationEuler, t));
                rectTransform.pivot            = Vector2.Lerp(TransformAnimationRecords_HIDE[i - 1].Pivot, TransformAnimationRecords_HIDE[i].Pivot, t);
                rectTransform.anchorMin        = Vector2.Lerp(TransformAnimationRecords_HIDE[i - 1].AnchorMin, TransformAnimationRecords_HIDE[i].AnchorMin, t);
                rectTransform.anchorMax        = Vector2.Lerp(TransformAnimationRecords_HIDE[i - 1].AnchorMax, TransformAnimationRecords_HIDE[i].AnchorMax, t);

                yield return(null);
            }

            #region Set Final Values

            rectTransform.anchoredPosition = TransformAnimationRecords_HIDE[i].Position;
            rectTransform.localScale       = TransformAnimationRecords_HIDE[i].Scale;
            rectTransform.rotation         = Quaternion.LookRotation(TransformAnimationRecords_HIDE[i].RotationEuler);
            rectTransform.pivot            = TransformAnimationRecords_HIDE[i].Pivot;
            rectTransform.anchorMin        = TransformAnimationRecords_HIDE[i].AnchorMin;
            rectTransform.anchorMax        = TransformAnimationRecords_HIDE[i].AnchorMax;

            #endregion
        }

        gameObject.SetActive(false);

        if (OnHideComplete != null)
        {
            OnHideComplete.Invoke();
        }
    }
    private IEnumerator AnimateTransformAndGraphic_HIDE()
    {
        if (withDelay)
        {
            yield return(new WaitForSeconds(hideDelay));
        }

        for (int i = 1; i < TransformAndGraphicAnimationRecords_HIDE.Count; i++)
        {
            if (TransformAndGraphicAnimationRecords_HIDE[i - 1].Delay > 0)
            {
                yield return(new WaitForSeconds(TransformAndGraphicAnimationRecords_HIDE[i - 1].Delay));
            }

            float startTime = Time.time;
            while (Time.time <= TransformAndGraphicAnimationRecords_HIDE[i - 1].Duration + startTime)
            {
                float t = (Time.time - startTime) / TransformAndGraphicAnimationRecords_HIDE[i - 1].Duration;

                rectTransform.anchoredPosition = Vector3.Lerp(TransformAndGraphicAnimationRecords_HIDE[i - 1].Position, TransformAndGraphicAnimationRecords_HIDE[i].Position, t);
                rectTransform.localScale       = Vector3.Lerp(TransformAndGraphicAnimationRecords_HIDE[i - 1].Scale, TransformAndGraphicAnimationRecords_HIDE[i].Scale, t);
                rectTransform.rotation         = Quaternion.Euler(Vector3.Lerp(TransformAndGraphicAnimationRecords_HIDE[i - 1].RotationEuler, TransformAndGraphicAnimationRecords_HIDE[i].RotationEuler, t));
                rectTransform.pivot            = Vector2.Lerp(TransformAndGraphicAnimationRecords_HIDE[i - 1].Pivot, TransformAndGraphicAnimationRecords_HIDE[i].Pivot, t);
                rectTransform.anchorMin        = Vector2.Lerp(TransformAndGraphicAnimationRecords_HIDE[i - 1].AnchorMin, TransformAndGraphicAnimationRecords_HIDE[i].AnchorMin, t);
                rectTransform.anchorMax        = Vector2.Lerp(TransformAndGraphicAnimationRecords_HIDE[i - 1].AnchorMax, TransformAndGraphicAnimationRecords_HIDE[i].AnchorMax, t);

                if (graphicType == GraphicType.Image)
                {
                    Image img = graphic as Image;
                    if (TransformAndGraphicAnimationRecords_HIDE[i].Sprite)
                    {
                        img.sprite = TransformAndGraphicAnimationRecords_HIDE[i].Sprite;
                    }
                    img.color = Color.Lerp(TransformAndGraphicAnimationRecords_HIDE[i - 1].Color, TransformAndGraphicAnimationRecords_HIDE[i].Color, t);
                }

                else if (graphicType == GraphicType.Text)
                {
                    Text txt = graphic as Text;
                    if (!string.IsNullOrEmpty(TransformAndGraphicAnimationRecords_HIDE[i].Text))
                    {
                        txt.text = TransformAndGraphicAnimationRecords_HIDE[i].Text;
                    }
                    txt.color = Color.Lerp(TransformAndGraphicAnimationRecords_HIDE[i - 1].Color, TransformAndGraphicAnimationRecords_HIDE[i].Color, t);
                }

                yield return(null);
            }

            #region Set Final Values

            rectTransform.anchoredPosition = TransformAndGraphicAnimationRecords_HIDE[i].Position;
            rectTransform.localScale       = TransformAndGraphicAnimationRecords_HIDE[i].Scale;
            rectTransform.rotation         = Quaternion.LookRotation(TransformAndGraphicAnimationRecords_HIDE[i].RotationEuler);
            rectTransform.pivot            = TransformAndGraphicAnimationRecords_HIDE[i].Pivot;
            rectTransform.anchorMin        = TransformAndGraphicAnimationRecords_HIDE[i].AnchorMin;
            rectTransform.anchorMax        = TransformAndGraphicAnimationRecords_HIDE[i].AnchorMax;

            if (graphicType == GraphicType.Image)
            {
                Image img = graphic as Image;
                if (TransformAndGraphicAnimationRecords_HIDE[i].Sprite)
                {
                    img.sprite = TransformAndGraphicAnimationRecords_HIDE[i].Sprite;
                }
                img.color = TransformAndGraphicAnimationRecords_HIDE[i].Color;
            }
            else if (graphicType == GraphicType.Text)
            {
                Text txt = graphic as Text;
                if (!string.IsNullOrEmpty(TransformAndGraphicAnimationRecords_HIDE[i].Text))
                {
                    txt.text = TransformAndGraphicAnimationRecords_HIDE[i].Text;
                }
                txt.color = TransformAndGraphicAnimationRecords_HIDE[i].Color;
            }

            #endregion
        }

        gameObject.SetActive(false);

        if (OnHideComplete != null)
        {
            OnHideComplete.Invoke();
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// Change the visibilty of the menu instantly without playing animation.
    /// </summary>
    /// <param name="visible">Should this menu be visible or not?</param>
    /// <param name="trivial">If true, sounds won't play and events won't fire</param>
    public override void ChangeVisibilityImmediate(bool visible, bool trivial = false)
    {
        forceVisibilityCall = true;

        if (!Initialized)
        {
            InitializeElements();
        }
        if (!gameObject.activeSelf)
        {
            gameObject.SetActive(true);
        }

        if (!UseSimpleActivation)
        {
            foreach (UIElement e in AnimatedElements)
            {
                if (e == null || !e.MenuDependent)
                {
                    continue;
                }

                e.ChangeVisibilityImmediate(visible);
            }
        }
        else
        {
            gameObject.SetActive(visible);
        }

        if (Visible != visible && !trivial)
        {
            if (SFXManager.Instance)
            {
                SFXManager.Instance.PlayClip(visible ? ShowingClip : HidingClip);
            }
            else if (ShowingClip || HidingClip)
            {
                Debug.LogError("You're trying to play sounds with no SFXManager in the scene. Please add one via Tools>ZUI>Creation Window...>Setup", gameObject);
            }
        }

        Visible = visible;

        if (!trivial)
        {
            if (visible)
            {
                if (OnShow != null)
                {
                    OnShow.Invoke();
                }
                if (OnShowComplete != null)
                {
                    OnShowComplete.Invoke();
                }
            }
            else if (!visible)
            {
                if (OnHide != null)
                {
                    OnHide.Invoke();
                }
                if (OnHideComplete != null)
                {
                    OnHideComplete.Invoke();
                }
            }
        }

        if (DeactivateWhileInvisible && !visible)
        {
            DeactivateMe(false);
        }
    }
Exemplo n.º 5
0
        private void HideComplete()
        {
            gameObject.SetActive(false);

            OnHideComplete?.Invoke();
        }
Exemplo n.º 6
0
        public override void ChangeVisibilityImmediate(bool visible, bool ignoreEvent = false)
        {
            forceVisibilityCall = true;

            if (!Initialized)
            {
                Initialize();
            }
            if (!gameObject.activeSelf)
            {
                gameObject.SetActive(true);
            }

            Visible = visible;
            if (!ignoreEvent)
            {
                if (visible)
                {
                    OnShow?.Invoke();
                    OnShowComplete?.Invoke();
                }
                else
                {
                    OnHide?.Invoke();
                    OnHideComplete?.Invoke();
                }
            }

            if (UseSimpleActivation)
            {
                gameObject.SetActive(visible);
                return;
            }
            if (MovementSection.UseSection)
            {
                Vector3 ePos = visible ? MovementSection.startVectorValue : outOfScreenPos;
                selfRectTransform.position = ePos;
            }
            if (RotationSection.UseSection)
            {
                Vector3 eEuler = visible ? RotationSection.startVectorValue : RotationSection.WantedVectorValue;
                selfRectTransform.eulerAngles = eEuler;
            }
            if (ScaleSection.UseSection)
            {
                Vector3 eScale = visible ? ScaleSection.startVectorValue : ScaleSection.WantedVectorValue;
                selfRectTransform.localScale = eScale;
            }
            if (OpacitySection.UseSection)
            {
                float eOpacity = visible ? OpacitySection.startFloatValue : OpacitySection.WantedFloatValue;
                if (TargetFader)
                {
                    if (TargetFader is Graphic)
                    {
                        Graphic tf  = (Graphic)TargetFader;
                        Color   col = tf.color;
                        col.a    = eOpacity;
                        tf.color = col;
                    }
                    else if (TargetFader is CanvasGroup)
                    {
                        CanvasGroup tf = (CanvasGroup)TargetFader;
                        tf.alpha = eOpacity;
                    }
                }
            }
            if (SliceSection.UseSection)
            {
                float eFill = visible ? SliceSection.startFloatValue : SliceSection.WantedFloatValue;
                if (SliceImage)
                {
                    SliceImage.fillAmount = eFill;
                }
            }

            if (DeactivateWhileInvisible && !visible)
            {
                gameObject.SetActive(false);
            }
        }
Exemplo n.º 7
0
        public override void ChangeVisibility(bool visible, bool ignoreEvent = false)
        {
            forceVisibilityCall = true;

            if (!Initialized)
            {
                Initialize();
            }

            if (!gameObject.activeSelf)
            {
                if (!UseSimpleActivation)
                {
                    if (MovementSection.UseSection)
                    {
                        Vector3 ePos = visible ? MovementSection.startVectorValue : outOfScreenPos;
                        selfRectTransform.position = ePos;
                    }
                    if (RotationSection.UseSection)
                    {
                        Vector3 eEuler = visible ? RotationSection.startVectorValue : RotationSection.WantedVectorValue;
                        selfRectTransform.eulerAngles = eEuler;
                    }
                    if (ScaleSection.UseSection)
                    {
                        Vector3 eScale = visible ? ScaleSection.startVectorValue : ScaleSection.WantedVectorValue;
                        selfRectTransform.localScale = eScale;
                    }
                    if (OpacitySection.UseSection)
                    {
                        float eOpacity = visible ? OpacitySection.startFloatValue : OpacitySection.WantedFloatValue;
                        if (TargetFader)
                        {
                            if (TargetFader is Graphic)
                            {
                                Graphic tf  = (Graphic)TargetFader;
                                Color   col = tf.color;
                                col.a    = eOpacity;
                                tf.color = col;
                            }
                            else if (TargetFader is CanvasGroup)
                            {
                                CanvasGroup tf = (CanvasGroup)TargetFader;
                                tf.alpha = eOpacity;
                            }
                        }
                    }
                    if (SliceSection.UseSection)
                    {
                        float eFill = visible ? SliceSection.startFloatValue : SliceSection.WantedFloatValue;
                        if (SliceImage)
                        {
                            SliceImage.fillAmount = eFill;
                        }
                    }
                }
                gameObject.SetActive(true);
            }

            Visible = visible;
            if (!ignoreEvent)
            {
                if (startEventEnum != null)
                {
                    StopCoroutine(startEventEnum);
                    startEventEnum = null;
                }

                if (completeEventEnum != null)
                {
                    StopCoroutine(completeEventEnum);
                    completeEventEnum = null;
                }

                if (visible)
                {
                    if (OnShow != null)
                    {
                        startEventEnum = Yielders.DelayCallEvent(OnShow, ShowAfter);
                    }
                    if (OnShowComplete != null)
                    {
                        completeEventEnum = Yielders.DelayCallEvent(OnShowComplete, showingTime);
                    }
                }
                else
                {
                    if (OnHide != null)
                    {
                        startEventEnum = Yielders.DelayCallEvent(OnHide, HideAfter);
                    }
                    if (OnHideComplete != null)
                    {
                        completeEventEnum = Yielders.DelayCallEvent(OnHideComplete, hidingTime);
                    }
                }

                if (gameObject.activeInHierarchy)
                {
                    if (startEventEnum != null)
                    {
                        StartCoroutine(startEventEnum);
                    }
                    if (completeEventEnum != null)
                    {
                        StartCoroutine(completeEventEnum);
                    }
                }
            }

            if (UseSimpleActivation)
            {
                gameObject.SetActive(visible);
                if (startEventEnum != null)
                {
                    StopCoroutine(startEventEnum);
                    startEventEnum = null;
                }

                if (completeEventEnum != null)
                {
                    StopCoroutine(completeEventEnum);
                    completeEventEnum = null;
                }
                if (!ignoreEvent)
                {
                    if (visible)
                    {
                        OnShow?.Invoke();
                        OnShowComplete?.Invoke();
                    }
                    else
                    {
                        OnHide?.Invoke();
                        OnHideComplete?.Invoke();
                    }
                }
                return;
            }

            if (MovementSection.UseSection)
            {
                enMotionType        type         = GetSectionType(MovementSection);
                float               duration     = GetSectionDuration(MovementSection);
                EquationsParameters easingParams = GetEasingParams(MovementSection);
                ControlMovement(visible, type, HidingPosition, duration, easingParams, EdgeGap, MovementSection.WantedVectorValue, LocalCustomPosition);
            }
            if (RotationSection.UseSection)
            {
                enMotionType        type         = GetSectionType(RotationSection);
                float               duration     = GetSectionDuration(RotationSection);
                EquationsParameters easingParams = GetEasingParams(RotationSection);
                ControlRotation(visible, type, visible ? ShowingDirection : HidingDirection, RotationSection.WantedVectorValue, duration, easingParams);
            }
            if (ScaleSection.UseSection)
            {
                enMotionType        type         = GetSectionType(ScaleSection);
                float               duration     = GetSectionDuration(ScaleSection);
                EquationsParameters easingParams = GetEasingParams(ScaleSection);
                ControlScale(visible, type, ScaleSection.WantedVectorValue, duration, easingParams);
            }
            if (OpacitySection.UseSection)
            {
                enMotionType        type         = GetSectionType(OpacitySection);
                float               duration     = GetSectionDuration(OpacitySection);
                EquationsParameters easingParams = GetEasingParams(OpacitySection);
                ControlOpacity(visible, type, OpacitySection.WantedFloatValue, duration, easingParams);
            }
            if (SliceSection.UseSection)
            {
                enMotionType        type         = GetSectionType(SliceSection);
                float               duration     = GetSectionDuration(SliceSection);
                EquationsParameters easingParams = GetEasingParams(SliceSection);
                ControlSlice(visible, type, SliceSection.WantedFloatValue, duration, easingParams);
            }
        }
 private void OnHideFinish()
 {
     OnHideComplete?.Invoke();
     gameObject.SetActive(false);
 }
Exemplo n.º 9
0
    /// <summary>
    /// Change the visibility of this element instantly without playing animation.
    /// </summary>
    /// <param name="visible">Should this element be visible or not?</param>
    /// <param name="trivial">If true, sounds won't play and events won't fire</param>
    public override void ChangeVisibilityImmediate(bool visible, bool trivial = false)
    {
        forceVisibilityCall = true;

        if (!Initialized)
        {
            Initialize();
        }
        if (!gameObject.activeSelf)
        {
            gameObject.SetActive(true);
        }


        //Only play sound effects if visibility has changed.
        if (Visible != visible && !trivial)
        {
            if (SFXManager.Instance)
            {
                SFXManager.Instance.PlayClip(visible ? ShowingClip : HidingClip);
            }
            else if (ShowingClip || HidingClip)
            {
                Debug.LogError("You're trying to play sounds with no SFXManager in the scene. Please add one via Tools>ZUI>Creation Window...>Setup", gameObject);
            }
        }

        Visible = visible;

        if (!trivial)
        {
            if (visible)
            {
                if (OnShow != null)
                {
                    OnShow.Invoke();
                }
                if (OnShowComplete != null)
                {
                    OnShowComplete.Invoke();
                }
            }
            else if (!visible)
            {
                if (OnHide != null)
                {
                    OnHide.Invoke();
                }
                if (OnHideComplete != null)
                {
                    OnHideComplete.Invoke();
                }
            }
        }

        //If this element is set to use simple activation (enabling and disabling the gameObject) then do it and get out of the function.
        if (UseSimpleActivation)
        {
            gameObject.SetActive(visible);
            return;
        }

        //Switch visiblity states in all the used animation sections.
        if (MovementSection.UseSection)
        {
            Vector3 ePos = visible ? MovementSection.startVectorValue : outOfScreenPos;
            myRT.position = ePos;
        }
        if (RotationSection.UseSection)
        {
            Vector3 eEuler = visible ? RotationSection.startVectorValue : RotationSection.WantedVectorValue;
            myRT.eulerAngles = eEuler;
        }
        if (ScaleSection.UseSection)
        {
            Vector3 eScale = visible ? ScaleSection.startVectorValue : ScaleSection.WantedVectorValue;
            myRT.localScale = eScale;
        }
        if (OpacitySection.UseSection)
        {
            float eOpacity = visible ? OpacitySection.startFloatValue : OpacitySection.WantedFloatValue;
            if (TargetFader)
            {
                if (TargetFader is Graphic)
                {
                    Graphic tf  = TargetFader as Graphic;
                    Color   col = tf.color;
                    col.a    = eOpacity;
                    tf.color = col;
                }
                else if (TargetFader is CanvasGroup)
                {
                    CanvasGroup tf = TargetFader as CanvasGroup;
                    tf.alpha = eOpacity;
                }
            }
        }
        if (SliceSection.UseSection)
        {
            float eFill = visible ? SliceSection.startFloatValue : SliceSection.WantedFloatValue;
            if (SliceImage)
            {
                SliceImage.fillAmount = eFill;
            }
        }

        if (DeactivateWhileInvisible && !visible)
        {
            DeactivateMe(false);
        }
    }
Exemplo n.º 10
0
        public override void ChangeVisibility(bool visible, bool ignoreEvent = false)
        {
            if (!Initialized)
            {
                InitializeElements();
            }

            if (!gameObject.activeSelf)
            {
                gameObject.SetActive(true);
            }

            if (!UseSimpleActivation)
            {
                foreach (UIAnimationElement e in AnimatedElements)
                {
                    if (e == null || !e.IsDependent)
                    {
                        continue;
                    }
                    e.ChangeVisibility(visible, ignoreEvent);
                }
            }
            else
            {
                gameObject.SetActive(visible);
            }

            foreach (UIAnimationElement e in SharedAnimatedElements)
            {
                if (e == null || !e.IsDependent)
                {
                    continue;
                }
                if (visible)
                {
                    if (!UseSimpleActivation)
                    {
                        if (!e.gameObject.activeSelf)
                        {
                            e.gameObject.SetActive(true);
                        }
                        e.ChangeVisibility(true, ignoreEvent);
                    }
                    else
                    {
                        e.gameObject.SetActive(true);
                        e.ChangeVisibilityImmediate(true, ignoreEvent);
                    }
                }
            }

            Visible = visible;

            if (!ignoreEvent)
            {
                if (completeEventEnum != null)
                {
                    StopCoroutine(completeEventEnum);
                    completeEventEnum = null;
                }

                if (visible)
                {
                    OnShow?.Invoke();
                    if (OnShowComplete != null)
                    {
                        completeEventEnum = Yielders.DelayCallEvent(OnShowComplete, showingTime);
                    }
                }
                else
                {
                    OnHide?.Invoke();
                    if (OnHideComplete != null)
                    {
                        completeEventEnum = Yielders.DelayCallEvent(OnHideComplete, hidingTime);
                    }
                }

                if (gameObject.activeInHierarchy)
                {
                    if (completeEventEnum != null)
                    {
                        StartCoroutine(completeEventEnum);
                    }
                }

                if (UseSimpleActivation)
                {
                    if (completeEventEnum != null)
                    {
                        StopCoroutine(completeEventEnum);
                        completeEventEnum = null;
                    }
                    if (visible)
                    {
                        OnShowComplete?.Invoke();
                    }
                    else
                    {
                        OnHideComplete?.Invoke();
                    }
                }
            }
        }
Exemplo n.º 11
0
        public override void ChangeVisibilityImmediate(bool visible, bool ignoreEvent = false)
        {
            if (!Initialized)
            {
                InitializeElements();
            }

            if (!gameObject.activeSelf)
            {
                gameObject.SetActive(true);
            }

            if (!UseSimpleActivation)
            {
                foreach (UIAnimationElement e in AnimatedElements)
                {
                    if (e == null || !e.IsDependent)
                    {
                        continue;
                    }

                    e.ChangeVisibilityImmediate(visible, ignoreEvent);
                }
            }
            else
            {
                gameObject.SetActive(visible);
            }

            foreach (UIAnimationElement e in SharedAnimatedElements)
            {
                if (e == null || !e.IsDependent)
                {
                    continue;
                }

                if (visible)
                {
                    if (!UseSimpleActivation)
                    {
                        if (!e.gameObject.activeSelf)
                        {
                            e.gameObject.SetActive(true);
                        }
                        e.ChangeVisibilityImmediate(true, ignoreEvent);
                    }
                    else
                    {
                        e.gameObject.SetActive(true);
                    }
                }
            }

            Visible = visible;

            if (!ignoreEvent)
            {
                if (visible)
                {
                    OnShow?.Invoke();
                    OnShowComplete?.Invoke();
                }
                else
                {
                    OnHide?.Invoke();
                    OnHideComplete?.Invoke();
                }
            }

            if (DeactivateWhileInvisible && !visible)
            {
                gameObject.SetActive(false);
            }
        }