public UIZoomButton( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, UIUVRect highlightedUVframe ):base( manager, frame, depth, uvFrame, highlightedUVframe )
	{
		centerize();
		autoRefreshPositionOnScaling = false;
		_zoomInAnimation = new UIAnimation( this, 0.3f, UIAnimationProperty.Scale, new Vector3( 1, 1, 1 ), new Vector3( 1.3f, 1.3f, 1.3f ), Easing.Quartic.easeInOut );
		_zoomOutAnimation = new UIAnimation( this, 0.3f, UIAnimationProperty.Scale, new Vector3( 1.3f, 1.3f, 1.3f ), new Vector3( 1, 1, 1 ), Easing.Quartic.easeInOut );
	}
Пример #2
0
	public bool Animate (UIAnimation animation, RectTransform rect=null) {
		if (!AllowSimultaneous && Animating)
			return false;
		animation.Rect = rect == null ? gameObject.GetComponent<RectTransform> () : rect;
		currentAnimation = animation;
		animation.Start ();
		return true;
	}
Пример #3
0
    void Start()
    {
        animateBtn = false;
        animateForward = false;
        Instance = this;

        originalPosition = uiElements[0].transform.position;

        menuOpenPosition = new Vector3[uiElements.Length];
        res = Screen.currentResolution;

        SetPositions();
    }
Пример #4
0
 void Awake()
 {
     Instance = this;
 }
	// Sets up and starts a new animation in a Coroutine - Vector3 version
	private static UIAnimation animate( UIObject sprite, float duration, UIAnimationProperty aniProperty, Vector3 start, Vector3 target, UIEaseType ease )
	{
		var ani = new UIAnimation( sprite, duration, aniProperty, start, target, ease );
		UI.Instance.StartCoroutine( ani.animate() );
		
		return ani;
	}
Пример #6
0
        public static void PreviewButtonAnimation(UIAnimation animation, RectTransform rectTransform, CanvasGroup canvasGroup)
        {
            if (s_previewIsPlaying)
            {
                return;
            }
            if (s_delayedCall != null)
            {
                s_delayedCall.Cancel();
            }
            StopButtonPreview(rectTransform, canvasGroup);

            RectTransform target = rectTransform;

            s_startPosition = target.anchoredPosition3D;
            s_startRotation = target.localRotation.eulerAngles;
            s_startScale    = target.localScale;
            s_startAlpha    = canvasGroup.alpha;

            StopAllAnimations(target);

            Vector3 moveFrom = UIAnimator.GetAnimationMoveFrom(rectTransform, animation, s_startPosition);
            Vector3 moveTo   = UIAnimator.GetAnimationMoveTo(rectTransform, animation, s_startPosition);

            if (!animation.Move.Enabled)
            {
                target.anchoredPosition3D = s_startPosition;
            }
            else
            {
                PreviewMove(rectTransform, moveFrom, moveTo, animation, s_startPosition);
            }

            Vector3 rotateFrom = UIAnimator.GetAnimationRotateFrom(animation, s_startRotation);
            Vector3 rotateTo   = UIAnimator.GetAnimationRotateTo(animation, s_startRotation);

            if (!animation.Rotate.Enabled)
            {
                target.localRotation = Quaternion.Euler(s_startRotation);
            }
            else
            {
                PreviewRotate(rectTransform, rotateFrom, rotateTo, animation, s_startRotation);
            }

            Vector3 scaleFrom = UIAnimator.GetAnimationScaleFrom(animation, s_startScale);
            Vector3 scaleTo   = UIAnimator.GetAnimationScaleTo(animation, s_startScale);

            if (!animation.Scale.Enabled)
            {
                target.localScale = s_startScale;
            }
            else
            {
                PreviewScale(rectTransform, scaleFrom, scaleTo, animation, s_startScale);
            }

            float fadeFrom = UIAnimator.GetAnimationFadeFrom(animation, s_startAlpha);
            float fadeTo   = UIAnimator.GetAnimationFadeTo(animation, s_startAlpha);

            if (!animation.Fade.Enabled)
            {
                canvasGroup.alpha = s_startAlpha;
            }
            else
            {
                PreviewFade(rectTransform, fadeFrom, fadeTo, animation, s_startAlpha);
            }

            DOTweenEditorPreview.Start();
            s_previewIsPlaying = true;

            s_delayedCall = new DelayedCall((animation.AnimationType == AnimationType.Loop ? 5f : animation.TotalDuration + (animation.AnimationType == AnimationType.Hide || animation.AnimationType == AnimationType.State ? 0.5f : 0f)), () =>
            {
                StopButtonPreview(rectTransform, canvasGroup);
                s_delayedCall = null;
            });
        }
Пример #7
0
        public static void PreviewPopupAnimation(UIPopup popup, UIAnimation animation)
        {
            if (s_previewIsPlaying)
            {
                return;
            }
            if (s_delayedCall != null)
            {
                s_delayedCall.Cancel();
            }
            StopPopupPreview(popup);
            StopAllAnimations(popup.RectTransform);
            if (popup.HasContainer)
            {
                StopAllAnimations(popup.Container.RectTransform);
            }
            if (popup.HasOverlay)
            {
                StopAllAnimations(popup.RectTransform);
            }

            Vector3 moveFrom = UIAnimator.GetAnimationMoveFrom(popup.Container.RectTransform, animation, popup.Container.StartPosition);
            Vector3 moveTo   = UIAnimator.GetAnimationMoveTo(popup.Container.RectTransform, animation, popup.Container.StartPosition);

            if (!animation.Move.Enabled)
            {
                popup.Container.ResetPosition();
            }
            else
            {
                PreviewMove(popup.Container.RectTransform, moveFrom, moveTo, animation, popup.Container.StartPosition);
            }

            Vector3 rotateFrom = UIAnimator.GetAnimationRotateFrom(animation, popup.Container.StartRotation);
            Vector3 rotateTo   = UIAnimator.GetAnimationRotateTo(animation, popup.Container.StartRotation);

            if (!animation.Rotate.Enabled)
            {
                popup.Container.ResetRotation();
            }
            else
            {
                PreviewRotate(popup.Container.RectTransform, rotateFrom, rotateTo, animation, popup.Container.StartRotation);
            }

            Vector3 scaleFrom = UIAnimator.GetAnimationScaleFrom(animation, popup.Container.StartScale);
            Vector3 scaleTo   = UIAnimator.GetAnimationScaleTo(animation, popup.Container.StartScale);

            if (!animation.Scale.Enabled)
            {
                popup.Container.ResetScale();
            }
            else
            {
                PreviewScale(popup.Container.RectTransform, scaleFrom, scaleTo, animation, popup.Container.StartScale);
            }

            float fadeFrom = UIAnimator.GetAnimationFadeFrom(animation, popup.Container.StartAlpha);
            float fadeTo   = UIAnimator.GetAnimationFadeTo(animation, popup.Container.StartAlpha);

            if (!animation.Fade.Enabled)
            {
                popup.Container.ResetAlpha();
            }
            else
            {
                PreviewFade(popup.Container.RectTransform, fadeFrom, fadeTo, animation, popup.Container.StartAlpha);
            }

            if (animation.Enabled && popup.HasOverlay && popup.Overlay.Enabled)
            {
                float overlayFadeFrom = animation.AnimationType == AnimationType.Show ? 0 : 1;
                float overlayFadeTo   = animation.AnimationType == AnimationType.Show ? 1 : 0;
                popup.Overlay.CanvasGroup.alpha = overlayFadeFrom;
                DOTweenEditorPreview.PrepareTweenForPreview(popup.Overlay.CanvasGroup.DOFade(overlayFadeTo, animation.TotalDuration), true, true, false);
            }

            DOTweenEditorPreview.Start();
            s_previewIsPlaying = true;

            s_delayedCall = new DelayedCall(animation.TotalDuration + (animation.AnimationType == AnimationType.Hide ? 0.5f : 0f), () =>
            {
                StopPopupPreview(popup);
                s_delayedCall = null;
            });
        }
    void Start()
    {
        if (Application.isPlaying && uiAnimation != null)
        {
            return;
        }

        rect = GetComponent <RectTransform>();
        UpdateBehaviour mMod = EasyUIAnimatorUtils.GetModifier(mod);

        Effect.EffectUpdate mEff = EasyUIAnimatorUtils.GetEffect(effect, max, bounce);
        effectRotation = (randomDirection) ? Vector3.forward * Random.Range(0, 360) : effectRotation;
        switch (animType)
        {
        case AnimationType.MOVE:
            if (useScreenValues)
            {
                uiAnimation = UIAnimator.Move(rect, Vector3.Scale(startV3, (Vector3)UIAnimator.InvertedScreenDimension), Vector3.Scale(finalV3, (Vector3)UIAnimator.InvertedScreenDimension), duration).SetDelay(delay).SetModifier(mMod).SetEffect(mEff, Quaternion.Euler(effectRotation));
            }
            else
            {
                uiAnimation = UIAnimator.Move(rect, startV3, finalV3, duration).SetDelay(delay).SetModifier(mMod).SetEffect(mEff, Quaternion.Euler(effectRotation));
            }
            break;

        case AnimationType.SCALE:
            uiAnimation = UIAnimator.Scale(rect, startV3, finalV3, duration).SetDelay(delay).SetModifier(mMod).SetEffect(mEff, Quaternion.Euler(effectRotation));
            break;

        case AnimationType.ROTATION:
            if (startV3.x != 0 || startV3.y != 0 || finalV3.x != 0 || finalV3.y != 0)
            {
                uiAnimation = UIAnimator.Rotate(rect, Quaternion.Euler(startV3), Quaternion.Euler(finalV3), duration).SetDelay(delay).SetModifier(mMod).SetEffect(mEff, Quaternion.Euler(effectRotation));
            }
            else
            {
                uiAnimation = UIAnimator.Rotate(rect, startV3.z, finalV3.z, duration).SetDelay(delay).SetModifier(mMod).SetEffect(mEff, Quaternion.Euler(effectRotation));
            }
            break;

        case AnimationType.IMAGE:
            image = GetComponent <Graphic>();
            if (!image)
            {
                Debug.LogError("Please attach an Image component to the gameObject");
                uiAnimation = null;
                return;
            }
            uiAnimation = UIAnimator.ChangeColor(image, startColor, finalColor, duration).SetDelay(delay).SetModifier(mMod);
            break;

        case AnimationType.GROUP:
            UIAnimation[] uiAnimations = new UIAnimation[fixedAnimations.Length];
            for (int i = 0; i < uiAnimations.Length; i++)
            {
                uiAnimations[i] = fixedAnimations[i].uiAnimation;
            }
            uiAnimation = new UIGroupAnimation(uiAnimations);
            break;

        default:
            break;
        }
        switch (loop)
        {
        case Loop.LOOP:
            uiAnimation.SetLoop();
            break;

        case Loop.PING_PONG:
            uiAnimation.SetLoop(true);
            break;
        }

        if (disableAfter)
        {
            uiAnimation.SetCallback(() => { gameObject.SetActive(false); });
        }
        if (Application.isPlaying)
        {
            if (playOnStart)
            {
                Play();
            }
        }
    }
Пример #9
0
 public void OnEnable()
 {
     StartCoroutine(UIAnimation.FadeIn(GetComponent <RectTransform>(), GetComponent <CanvasGroup>()));
 }