public static TweenRunner <ColorTween> TweenColor(this MonoBehaviour mb, Material material, Color fromColor,
                                                          Color toColor, float duration, ColorTween.ColorTweenMode colorTweenMode = ColorTween.ColorTweenMode.All,
                                                          EaseType easeType = EaseType.Linear, bool ignoreTimeScale = false, UnityAction onCompleteCallback = null)
        {
            var colorTween = new ColorTween
            {
                startColor      = fromColor,
                targetColor     = toColor,
                duration        = duration,
                ignoreTimeScale = ignoreTimeScale
            };

            colorTween.AddOnChangedCallback(newColor => material.color = newColor);

            if (onCompleteCallback != null)
            {
                colorTween.AddOnCompleteCallback(onCompleteCallback);
            }

            var tweenRunner = new TweenRunner <ColorTween>();

            tweenRunner.Init(mb);
            tweenRunner.StartTween(colorTween, easeType);

            return(tweenRunner);
        }
        void Awake()
        {
            m_Canvas      = GetComponent <Canvas>();
            m_CanvasGroup = GetComponent <CanvasGroup>();
            m_ScrollRect  = GetComponent <ScrollRect>();

            m_OpenDialogTween = new FloatTween()
            {
                duration        = UIConfig.dialogFadeTime,
                ignoreTimeScale = true
            };
            m_OpenDialogTween.AddOnChangedCallback(OnSetAlpha);
            m_OpenDialogTween.AddOnCompleteCallback(OnOpenTransitionComplete);
            m_CloseDialogTween = new FloatTween()
            {
                duration        = UIConfig.dialogFadeTime,
                ignoreTimeScale = true
            };
            m_CloseDialogTween.AddOnChangedCallback(OnSetAlpha);
            m_CloseDialogTween.AddOnCompleteCallback(OnCloseTransitionComplete);
            m_TweenRunner = new TweenRunner <FloatTween>();
            m_TweenRunner.Init(this);

            m_Open = m_Canvas.enabled;
        }
        public static TweenRunner <ScaleTween> TweenScale(this MonoBehaviour mb, Transform transform, Vector3 toScale,
                                                          float duration, EaseType easeType = EaseType.Linear, bool ignoreTimeScale = false,
                                                          UnityAction onCompleteCallback    = null)
        {
            var scaleTween = new ScaleTween
            {
                startScale      = transform.localScale,
                targetScale     = toScale,
                duration        = duration,
                ignoreTimeScale = ignoreTimeScale
            };

            scaleTween.AddOnChangedCallback(newScale => transform.localScale = newScale);

            if (onCompleteCallback != null)
            {
                scaleTween.AddOnCompleteCallback(onCompleteCallback);
            }

            var tweenRunner = new TweenRunner <ScaleTween>();

            tweenRunner.Init(mb);
            tweenRunner.StartTween(scaleTween, easeType);

            return(tweenRunner);
        }
        public static TweenRunner <RotationTween> TweenLocalRotation(this MonoBehaviour mb, Transform transform, Quaternion toRotation,
                                                                     float duration, EaseType easeType = EaseType.Linear, bool ignoreTimeScale = false,
                                                                     UnityAction onCompleteCallback    = null)
        {
            var rotationTween = new RotationTween
            {
                startRotation   = transform.localRotation,
                targetRotation  = toRotation,
                duration        = duration,
                ignoreTimeScale = ignoreTimeScale
            };

            rotationTween.AddOnChangedCallback(newRotation => transform.localRotation = newRotation);

            if (onCompleteCallback != null)
            {
                rotationTween.AddOnCompleteCallback(onCompleteCallback);
            }

            var tweenRunner = new TweenRunner <RotationTween>();

            tweenRunner.Init(mb);
            tweenRunner.StartTween(rotationTween, easeType);

            return(tweenRunner);
        }
        public static TweenRunner <PositionTween> TweenLocalPosition(this MonoBehaviour mb, Transform transform,
                                                                     Vector3 toPosition,
                                                                     float duration, EaseType easeType = EaseType.Linear, bool ignoreTimeScale = false,
                                                                     UnityAction onCompleteCallback    = null)
        {
            var positionTween = new PositionTween
            {
                startPosition   = mb.transform.position,
                targetPosition  = toPosition,
                duration        = duration,
                ignoreTimeScale = ignoreTimeScale
            };

            positionTween.AddOnChangedCallback(newPosition => transform.localPosition = newPosition);

            if (onCompleteCallback != null)
            {
                positionTween.AddOnCompleteCallback(onCompleteCallback);
            }

            var tweenRunner = new TweenRunner <PositionTween>();

            tweenRunner.Init(mb);
            tweenRunner.StartTween(positionTween, easeType);

            return(tweenRunner);
        }
 void Start()
 {
     m_SliderColorTween = new ColorTween()
     {
         duration        = k_SliderColorTransitionDuration,
         ignoreTimeScale = true,
         tweenMode       = ColorTween.ColorTweenMode.RGB
     };
     m_SliderColorTween.AddOnChangedCallback(SetSliderColor);
     m_SliderColorTweenRunner = new TweenRunner <ColorTween>();
     m_SliderColorTweenRunner.Init(this);
     onIntValueChanged.AddListener(v =>
     {
         m_Value = v;
         foreach (var handler in m_Handlers)
         {
             handler?.Invoke();
         }
     });
     onFloatValueChanged.AddListener(v =>
     {
         m_Value = v;
         foreach (var handler in m_Handlers)
         {
             handler?.Invoke();
         }
     });
 }
예제 #7
0
        public void Initialize()
        {
            if (m_Initialized)
            {
                return;
            }

            m_CurrentProgress = 0;
            m_ProgressTween   = new FloatTween
            {
                duration        = 0.1f,
                ignoreTimeScale = true,
            };
            m_ProgressTween.AddOnChangedCallback(OnProgressTweenChanged);

            m_LoopingTween = new FloatTween
            {
                duration        = m_LoopingDuration,
                ignoreTimeScale = true,
                startValue      = 0,
                targetValue     = -360,
            };
            m_LoopingTween.AddOnChangedCallback(OnLoopingTweenChanged);

            UpdateCorners();
            m_TweenRunner = new TweenRunner <FloatTween>();
            m_TweenRunner.Init(this);

            m_Initialized = true;
        }
예제 #8
0
 void Start()
 {
     m_SliderColorTween = new ColorTween()
     {
         duration        = k_SliderColorTransitionDuration,
         ignoreTimeScale = true,
         tweenMode       = ColorTween.ColorTweenMode.RGB
     };
     m_SliderColorTween.AddOnChangedCallback(SetSliderColor);
     m_SliderColorTweenRunner = new TweenRunner <ColorTween>();
     m_SliderColorTweenRunner.Init(this);
 }
예제 #9
0
        void Awake()
        {
            m_RectTransform = GetComponent <RectTransform>();

            m_MoveWindowTween = new FloatTween()
            {
                duration        = k_MoveWindowTransitionDuration,
                ignoreTimeScale = true,
                startValue      = 0f,
                targetValue     = 1f
            };
            m_MoveWindowTween.AddOnChangedCallback(OnMoveTab);
            m_MoveWindowTween.AddOnCompleteCallback(OnMoveTransitionComplete);
            m_MoveWindowTweenRunner = new TweenRunner <FloatTween>();
            m_MoveWindowTweenRunner.Init(this);
        }
        void Awake()
        {
            m_FoldTween = new RectTween()
            {
                duration        = UIConfig.widgetsFoldTime,
                ignoreTimeScale = true
            };
            m_FoldTween.AddOnChangedCallback(OnSetRect);
            m_FoldTween.AddOnCompleteCallback(OnFoldTransitionComplete);

            m_UnfoldTween = new RectTween()
            {
                duration        = UIConfig.widgetsFoldTime,
                ignoreTimeScale = true
            };
            m_UnfoldTween.AddOnChangedCallback(OnSetRect);
            m_UnfoldTween.AddOnCompleteCallback(OnUnfoldTransitionComplete);

            m_TweenRunner = new TweenRunner <RectTween>();
            m_TweenRunner.Init(this);
        }
예제 #11
0
        void Awake()
        {
            m_CurrentProgress = 0;
            m_ProgressTween   = new FloatTween
            {
                duration        = 0.1f,
                ignoreTimeScale = true,
            };
            m_ProgressTween.AddOnChangedCallback(OnProgressTweenChanged);

            m_LoopingTween = new FloatTween
            {
                duration        = m_LoopingDuration,
                ignoreTimeScale = true,
                startValue      = 0,
                targetValue     = -360,
            };
            m_LoopingTween.AddOnChangedCallback(OnLoopingTweenChanged);


            m_TweenRunner = new TweenRunner <FloatTween>();
            m_TweenRunner.Init(this);
        }
예제 #12
0
        void Awake()
        {
            m_Canvas      = GetComponent <Canvas>();
            m_CanvasGroup = GetComponent <CanvasGroup>();
            m_ScrollRect  = GetComponent <ScrollRect>();

            m_OpenDialogTween = new FloatTween()
            {
                duration        = UIConfig.dialogFadeTime,
                ignoreTimeScale = true
            };
            m_OpenDialogTween.AddOnChangedCallback(OnSetAlpha);
            m_OpenDialogTween.AddOnCompleteCallback(OnOpenTransitionComplete);
            m_CloseDialogTween = new FloatTween()
            {
                duration        = UIConfig.dialogFadeTime,
                ignoreTimeScale = true
            };
            m_CloseDialogTween.AddOnChangedCallback(OnSetAlpha);
            m_CloseDialogTween.AddOnCompleteCallback(OnCloseTransitionComplete);
            m_TweenRunner = new TweenRunner <FloatTween>();
            m_TweenRunner.Init(this);

            m_Open  = m_Canvas.enabled;
            m_Ready = true;

            switch (m_DelayedStatus)
            {
            case true:
                Open();
                break;

            case false:
                Close();
                break;
            }
        }
예제 #13
0
        void Awake()
        {
            m_OpenDialogTween = new FloatTween()
            {
                duration        = UIConfig.dialogFadeTime,
                ignoreTimeScale = true
            };
            m_OpenDialogTween.AddOnChangedCallback(OnSetAlpha);
            m_OpenDialogTween.AddOnCompleteCallback(OnOpenTransitionComplete);
            m_CloseDialogTween = new FloatTween()
            {
                duration        = UIConfig.dialogFadeTime,
                ignoreTimeScale = true
            };
            m_CloseDialogTween.AddOnChangedCallback(OnSetAlpha);
            m_CloseDialogTween.AddOnCompleteCallback(OnCloseTransitionComplete);
            m_TweenRunner = new TweenRunner <FloatTween>();
            m_TweenRunner.Init(this);

            if (m_Canvas != null)
            {
                m_Open = m_Canvas.enabled;
            }
        }