public override void HideElement()
    {
        OnHideComplete.AddListener(ResetAll);
        StopAllCoroutines();

        switch (componentsToAnimate_HIDE)
        {
        case (ComponentsToAnimate.Transform):
            StartCoroutine(AnimateTransform_HIDE());
            break;

        case (ComponentsToAnimate.Graphic):
            StartCoroutine(AnimateGraphic_HIDE());
            break;

        case (ComponentsToAnimate.Both):
            StartCoroutine(AnimateTransformAndGraphic_HIDE());
            break;
        }

        if (OnHide != null)
        {
            OnHide.Invoke();
        }
    }
Exemplo n.º 2
0
        public void InitializeElements()
        {
            if (Initialized)
            {
                return;
            }
            if (DeactivateWhileInvisible)
            {
                OnHideComplete.AddListener(() =>
                {
                    if (!Visible)
                    {
                        gameObject.SetActive(Visible);
                    }
                });
            }
            for (int i = 0; i < AnimatedElements.Count; i++)
            {
                if (AnimatedElements[i] != null)
                {
                    AnimatedElements[i].Initialize();
                }
                else
                {
                    AnimatedElements.RemoveAt(i);
                    i--;
                }
            }

            for (int i = 0; i < SharedAnimatedElements.Count; i++)
            {
                if (SharedAnimatedElements[i] != null)
                {
                    SharedAnimatedElements[i].Initialize();
                }
                else
                {
                    SharedAnimatedElements.RemoveAt(i);
                    i--;
                }
            }

            hidingTime  = GetAllHidingTime();
            showingTime = GetAllShowingTime();
            Initialized = true;
        }
Exemplo n.º 3
0
        public void Initialize()
        {
            if (Initialized)
            {
                return;
            }
            if (DeactivateWhileInvisible)
            {
                OnHideComplete.AddListener(() =>
                {
                    if (!Visible)
                    {
                        gameObject.SetActive(Visible);
                    }
                });
            }
            hidingTime                = GetAllHidingTime();
            showingTime               = GetAllShowingTime();
            selfRectTransform         = GetComponent <RectTransform>();
            parentCanvasScaler        = GetComponentInParent <CanvasScaler>();
            parentCanvasRectTransform = parentCanvasScaler.GetComponent <RectTransform>();
            if (transform.parent)
            {
                directParentRectTransform = transform.parent.GetComponent <RectTransform>();
            }

            Vector2 canvasLossyScale = parentCanvasRectTransform.lossyScale;

            canvasHalfWidth  = canvasLossyScale.x * parentCanvasRectTransform.rect.width / 2;
            canvasHalfHeight = canvasLossyScale.y * parentCanvasRectTransform.rect.height / 2;
            if (directParentRectTransform)
            {
                directParentHalfWidth  = canvasLossyScale.x * directParentRectTransform.rect.width / 2;
                directParentHalfHeight = canvasLossyScale.y * directParentRectTransform.rect.height / 2;
            }
            selfRectTransformWidth           = canvasLossyScale.x * selfRectTransform.rect.width;
            selfRectTransformHeight          = canvasLossyScale.y * selfRectTransform.rect.height;
            MovementSection.startVectorValue = selfRectTransform.position;
            outOfScreenPos = GetHidingPosition(HidingPosition, EdgeGap, MovementSection.WantedVectorValue, LocalCustomPosition);
            RotationSection.startVectorValue = selfRectTransform.eulerAngles;
            ScaleSection.startVectorValue    = selfRectTransform.localScale;
            FindTargetFader();
            FindSliceImage();
            Initialized = true;
        }