예제 #1
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (!needsReset && GUILayout.Button("Play Tween"))
            {
                try
                {
                    Tween tween = TweenModule.GenerateTween();
                    //Tween tween = TweenModule.transform.DOMoveX(2, 1);

                    DOTweenEditorPreview.PrepareTweenForPreview(tween);
                    DOTweenEditorPreview.Start();
                    needsReset = true;
                }
                catch (Exception e)
                {
                    Debug.Log("Could not preview: " + e);
                }
            }
            if (needsReset && GUILayout.Button("Reset Tween"))
            {
                //TweenModule.Tween.Rewind();
                //TweenModule.Tween.Kill();
                DOTweenEditorPreview.Stop(true);
                needsReset = false;
            }
        }
예제 #2
0
        private void SetValue(float value)
        {
            value = Target.ClampValueBetweenMinAndMax(value, Target.WholeNumbers);
            ResetSimulatorTween(false, false);
            m_simulatorTween = Target.GetAnimationTween(value,
                                                        Target.AnimateValue ? Target.AnimationDuration : 0,
                                                        Target.AnimateValue ? Target.AnimationEase : Progressor.DEFAULT_EASE,
                                                        Target.AnimateValue ? Target.AnimationIgnoresUnityTimescale : Progressor.DEFAULT_IGNORE_UNITY_TIMESCALE)
                               .OnComplete(() =>
            {
                ResetSimulatorTween(false, false);
                Target.OnValueUpdated();
            });

            if (!EditorApplication.isPlayingOrWillChangePlaymode)
            {
                DOTweenEditorPreview.PrepareTweenForPreview(m_simulatorTween, false, false);
                DOTweenEditorPreview.Start();
//                if (Target.AnimateValue)
//                {
//                    DOTweenEditorPreview.PrepareTweenForPreview(m_simulatorTween, false, false);
//                    DOTweenEditorPreview.Start();
//                }
//                else
//                {
//                    Target.SetValue(value);
//                }
            }
            else
            {
                Target.SetValue(value);
            }

            Target.OnValueUpdated();
        }
예제 #3
0
 void CompleteTween()
 {
     if (!EditorApplication.isPlaying)
     {
         DOTweenEditorPreview.Stop(true);
     }
     _tween = null;
 }
예제 #4
0
 public static void StopButtonPreview(RectTransform rectTransform, CanvasGroup canvasGroup)
 {
     DOTweenEditorPreview.Stop(true);
     if (s_previewIsPlaying)
     {
         ResetButtonToStartValues(rectTransform, canvasGroup);
     }
     s_previewIsPlaying = false;
 }
예제 #5
0
        public static void PrepareTween(Tween tween, bool clearCallbacks, bool preventAutoKill, bool andPlay)
        {
#if UNITY_EDITOR
            all.Add(tween);

            tween.onComplete += () => { CheckEndPreview(tween); };

            DOTweenEditorPreview.PrepareTweenForPreview(tween, clearCallbacks, preventAutoKill, andPlay);
#endif
        }
    public void StopAllAnimations()
    {
#if UNITY_EDITOR
        if (!Application.isPlaying)
        {
            DOTweenEditorPreview.Stop();
        }
#endif
        animationBack?.Kill();
        animation?.Kill();
    }
예제 #7
0
 public static void StopPopupPreview(UIPopup popup)
 {
     DOTweenEditorPreview.Stop(true);
     popup.ResetToStartValues();
     popup.Container.ResetToStartValues();
     if (popup.HasOverlay)
     {
         popup.Overlay.ResetToStartValues();
     }
     s_previewIsPlaying = false;
 }
        private void Play()
        {
            if (!Application.isPlaying)
            {
                EditorApplication.update += EditorUpdate;
                DOTweenEditorPreview.Start();
                FindRelatedAnimationControllers();
                sequencerController.OnSequenceFinishedPlayingEvent += StopPreview;
                lastFrameTime    = EditorApplication.timeSinceStartup;
                isPreviewPlaying = true;
            }

            sequencerController.Play();
        }
예제 #9
0
    private void PrepareAndPlayTweens(DOTweenPlayerSO player)
    {
        UIController uiController = (UIController)target;

        foreach (var tween in player.Editor_ProcessedTweens())
        {
            DOTweenEditorPreview.PrepareTweenForPreview(tween.GetTween());
        }

        foreach (var tween in player.Editor_ProcessedTweens())
        {
            DOTweenEditorPreview.Start();
        }
    }
    public void AnimateBack()
    {
        StopAllAnimations();
        animationBack = CreateAnimationBack;

#if UNITY_EDITOR
        if (!Application.isPlaying)
        {
            var animation = this.animationBack;
            DOTweenEditorPreview.PrepareTweenForPreview(animationBack);
            DOTweenEditorPreview.Start();
        }
#endif
    }
예제 #11
0
 private void ResetSimulatorTween(bool resetTweenTarget, bool resetProgress)
 {
     if (m_simulatorTween == null)
     {
         return;
     }
     m_simulatorTween.Kill(true);
     m_simulatorTween = null;
     if (resetProgress)
     {
         Target.SetProgress(0, true);
     }
     DOTweenEditorPreview.Stop();
     Target.OnValueUpdated();
 }
예제 #12
0
            public void Render(ref Rect position, SerializedProperty property)
            {
                Rect pos = position;

                pos.height = height;
                float indentWidth = INDENT_WIDTH * EditorGUI.indentLevel;

                Rect boxPos = pos;

                SetIndent(ref boxPos, indentWidth - _gap);
                GUI.Box(boxPos, string.Empty);

                pos.width -= BORDER_SIZE * 2;
                pos.x     += BORDER_SIZE;
                pos.y     += BORDER_SIZE;

                pos.height = _itemHeight;
                for (int i = 0; i < _parameterInfos.Length; i++)
                {
                    ParameterInfo parameterInfo = _parameterInfos[i];
                    parameterInfo.EditorGUI(pos, ref _parameters[i]);
                    pos.y += _itemHeight + _gap;
                }

                SetIndent(ref pos, indentWidth);
                if (GUI.Button(pos, _tween == null ? _methodInfo.Name : "Stop"))
                {
                    if (_tween == null)
                    {
                        _tween = (Tween)_methodInfo.Invoke(property.ReflectionGetTarget(), _parameters);
                        _tween.OnComplete(CompleteTween);
                        if (!EditorApplication.isPlaying)
                        {
                            DOTweenEditorPreview.PrepareTweenForPreview(_tween, false);
                            DOTweenEditorPreview.Start();
                        }
                    }
                    else
                    {
                        _tween.Kill();
                        CompleteTween();
                    }
                }
                SetIndent(ref pos, -indentWidth);

                position.y = pos.y + _itemHeight + _gap + BORDER_SIZE;
            }
        public void Play()
        {
            if (tweener == null)
            {
                return;
            }

            if (Application.isPlaying)
            {
                tweener.Play();
            }
            else
            {
#if UNITY_EDITOR
                DOTweenEditorPreview.PrepareTweenForPreview(tweener);
#endif
            }
        }
예제 #14
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (GUILayout.Button(_tween == null ? "Play" : "Stop"))
            {
                if (_tween == null)
                {
                    _tween = _target.Play();
                    _tween.OnComplete(CompleteTween);
                    DOTweenEditorPreview.PrepareTweenForPreview(_tween, false);
                    DOTweenEditorPreview.Start();
                }
                else
                {
                    _tween.Kill();
                    CompleteTween();
                }
            }
        }
예제 #15
0
        public static void PreviewFade(RectTransform target, float from, float to, UIAnimation animation, float startAlpha)
        {
            switch (animation.AnimationType)
            {
            case AnimationType.Show:
            case AnimationType.Hide:
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.FadeTween(target, animation, @from, to), true, true, false);
                break;

            case AnimationType.Loop:
                CanvasGroup canvasGroup = target.GetComponent <CanvasGroup>() != null?target.GetComponent <CanvasGroup>() : target.gameObject.AddComponent <CanvasGroup>();

                animation.Fade.From = Mathf.Clamp01(animation.Fade.From);
                canvasGroup.alpha   = animation.Fade.From;
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.FadeLoopTween(target, animation), true, true, false);
                break;

            case AnimationType.State:
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.FadeStateTween(target, animation, startAlpha), true, true, false);
                break;
            }
        }
예제 #16
0
        private void Simulate()
        {
            ResetSimulatorTween(false, true);
            m_simulatorTween = Target.GetAnimationTween(Target.MaxValue, m_simulatorDuration, m_simulatorEase, true)
                               .OnComplete(() =>
            {
                ResetSimulatorTween(false, true);
                Target.OnValueUpdated();
            });
            if (!EditorApplication.isPlayingOrWillChangePlaymode)
            {
                DOTweenEditorPreview.PrepareTweenForPreview(m_simulatorTween, false, false, true);
                DOTweenEditorPreview.Start();

                m_showProgressTargetsSimulationMessage = true;
            }
            else
            {
                m_simulatorTween.Play();
            }

            Target.OnValueUpdated();
        }
        private void StopPreview()
        {
            if (!Application.isPlaying)
            {
                EditorApplication.update -= EditorUpdate;
                DOTweenEditorPreview.Stop(true);
            }

            sequencerController.OnSequenceFinishedPlayingEvent -= StopPreview;
            for (int i = 0; i < activeSequencers.Length; i++)
            {
                AnimationSequencerController animationSequencerController = activeSequencers[i];
                if (animationSequencerController == null)
                {
                    continue;
                }

                animationSequencerController.Stop();
            }

            isPreviewPlaying = false;
            Repaint();
        }
예제 #18
0
        public static void PreviewScale(RectTransform target, Vector3 from, Vector3 to, UIAnimation animation, Vector3 startScale)
        {
            switch (animation.AnimationType)
            {
            case AnimationType.Show:
            case AnimationType.Hide:
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.ScaleTween(target, animation, @from, to), true, true, false);
                break;

            case AnimationType.Loop:
                target.localScale = animation.Scale.From;
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.ScaleLoopTween(target, animation), true, true, false);
                break;

            case AnimationType.Punch:
                target.localScale = startScale;
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.ScalePunchTween(target, animation), true, true, false);
                break;

            case AnimationType.State:
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.ScaleStateTween(target, animation, startScale), true, true, false);
                break;
            }
        }
예제 #19
0
        public static void PreviewRotate(RectTransform target, Vector3 from, Vector3 to, UIAnimation animation, Vector3 startRotation)
        {
            switch (animation.AnimationType)
            {
            case AnimationType.Show:
            case AnimationType.Hide:
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.RotateTween(target, animation, @from, to), true, true, false);
                break;

            case AnimationType.Loop:
                target.localRotation = Quaternion.Euler(UIAnimator.RotateLoopRotationA(animation, startRotation));
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.RotateLoopTween(target, animation, startRotation), true, true, false);
                break;

            case AnimationType.Punch:
                target.localRotation = Quaternion.Euler(startRotation);
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.RotatePunchTween(target, animation), true, true, false);
                break;

            case AnimationType.State:
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.RotateStateTween(target, animation, startRotation), true, true, false);
                break;
            }
        }
예제 #20
0
        public static void PreviewMove(RectTransform target, Vector3 from, Vector3 to, UIAnimation animation, Vector3 startPosition)
        {
            switch (animation.AnimationType)
            {
            case AnimationType.Show:
            case AnimationType.Hide:
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.MoveTween(target, animation, @from, to), true, true, false);
                break;

            case AnimationType.Loop:
                target.anchoredPosition3D = UIAnimator.MoveLoopPositionA(animation, startPosition);
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.MoveLoopTween(target, animation, startPosition), true, true, false);
                break;

            case AnimationType.Punch:
                target.anchoredPosition3D = startPosition;
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.MovePunchTween(target, animation), true, true, false);
                break;

            case AnimationType.State:
                DOTweenEditorPreview.PrepareTweenForPreview(UIAnimator.MoveStateTween(target, animation, startPosition), true, true, false);
                break;
            }
        }
예제 #21
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;
            });
        }
예제 #22
0
 static void PrepareTween(Tween t)
 {
     Debug.Log("EditorPreviewer ► AddTween");
     DOTweenEditorPreview.PrepareTweenForPreview(t);
 }
예제 #23
0
 public static void StopViewPreview(UIView view)
 {
     DOTweenEditorPreview.Stop(true);
     view.ResetToStartValues();
     s_previewIsPlaying = false;
 }
예제 #24
0
        public static void PreviewViewAnimation(UIView view, UIAnimation animation)
        {
            if (s_previewIsPlaying)
            {
                return;
            }
            if (s_delayedCall != null)
            {
                s_delayedCall.Cancel();
            }
            view.UpdateStartValues();
            StopViewPreview(view);
            StopAllAnimations(view.RectTransform);

            Vector3 moveFrom = UIAnimator.GetAnimationMoveFrom(view.RectTransform, animation, view.CurrentStartPosition);
            Vector3 moveTo   = UIAnimator.GetAnimationMoveTo(view.RectTransform, animation, view.CurrentStartPosition);

            if (!animation.Move.Enabled)
            {
                view.ResetPosition();
            }
            else
            {
                PreviewMove(view.RectTransform, moveFrom, moveTo, animation, view.CurrentStartPosition);
            }

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

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

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

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

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

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

            DOTweenEditorPreview.Start();
            s_previewIsPlaying = true;

            s_delayedCall = new DelayedCall((animation.AnimationType == AnimationType.Loop ? 5f : animation.TotalDuration + (animation.AnimationType == AnimationType.Hide ? 0.5f : 0f)), () =>
            {
                StopViewPreview(view);
                s_delayedCall = null;
            });
        }
예제 #25
0
        public static void PreviewPopupAnimation(UIPopup popup, UIAnimation animation)
        {
            if (s_previewIsPlaying)
            {
                return;
            }
            if (s_delayedCall != null)
            {
                s_delayedCall.Cancel();
            }
            popup.UpdateStartValues();
            StopPopupPreview(popup);
            StopAllAnimations(popup.RectTransform);
            if (popup.HasContainer)
            {
                popup.Container.UpdateStartValues();
                StopAllAnimations(popup.Container.RectTransform);
            }

            if (popup.HasOverlay)
            {
                popup.Overlay.UpdateStartValues();
                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;
            });
        }
예제 #26
0
 static void Play()
 {
     Debug.Log("EditorPreviewer ► Play");
     DOTweenEditorPreview.Start();
 }
예제 #27
0
 static void Stop()
 {
     Debug.Log("EditorPreviewer ► Stop and reset");
     DOTweenEditorPreview.Stop(true);
 }
예제 #28
0
        public static void StopTweens()
        {
#if UNITY_EDITOR
            DOTweenEditorPreview.Stop();
#endif
        }
예제 #29
0
 void CompleteTween()
 {
     DOTweenEditorPreview.Stop(true);
     _tween = null;
 }