コード例 #1
0
        /// <summary>
        /// Create a TweenSlider Component and start a tween
        /// </summary>
        /// <param name="go">GameObject to apply tween to</param>
        /// <param name="duration">Duration of tween</param>
        /// <param name="value">The ending value for the tween</param>
        /// <param name="finished">A optional callback to fire when the tween is done</param>
        /// <returns>Returns a reference to the new TweenAlpha component</returns>
        public static TweenSlider Tween(GameObject go, float duration, float value, UnityAction finished = null)
        {
            TweenSlider cls = TweenMain.Tween <TweenSlider>(go, duration, finished);

            cls.from = cls.value;
            cls.to   = value;
            cls.Start();
            return(cls);
        }
コード例 #2
0
ファイル: TweenRot.cs プロジェクト: zeya-anwar/UnicornBattle
        /// <summary>
        /// Create a TweenRot Component and start a tween
        /// </summary>
        /// <param name="go">GameObject to apply tween too</param>
        /// <param name="duration">Duration of tween</param>
        /// <param name="rot">The ending value for the tween</param>
        /// <param name="finished">A optional Callback to fire when the tween is done</param>
        /// <returns>Return reference to the new TweenRot component</returns>
        public static TweenRot Tween(GameObject go, float duration, Quaternion rot, UnityAction finished = null)
        {
            TweenRot cls = TweenMain.Tween <TweenRot>(go, duration, finished);

            cls.from = cls.value.eulerAngles;
            cls.to   = rot.eulerAngles;
            cls.Start();
            return(cls);
        }
コード例 #3
0
        /// <summary>
        /// Create a TweenCGAlpha Component and start a tween
        /// </summary>
        /// <param name="go">GameObject to apply tween too</param>
        /// <param name="duration">Duration of tween</param>
        /// <param name="alpha">The ending value for the tween</param>
        /// <param name="finished">A optional Callback to fire when the tween is done</param>
        /// <returns>Return reference to the new TweenCGAlpha component</returns>
        public static TweenCGAlpha Tween(GameObject go, float duration, float alpha, UnityAction finished = null)
        {
            TweenCGAlpha cls = TweenMain.Tween <TweenCGAlpha>(go, duration, finished);

            cls.from = cls.value;
            cls.to   = alpha;
            cls.Start();
            return(cls);
        }
コード例 #4
0
        /// <summary>
        /// Create a TweenScale Component and start a tween
        /// </summary>
        /// <param name="go">GameObject to apply tween too</param>
        /// <param name="duration">Duration of tween</param>
        /// <param name="scale">The ending value for the tween</param>
        /// <param name="finished">A optional Callback to fire when the tween is done</param>
        /// <returns>Return reference to the new TweenScale component</returns>
        public static TweenScale Tween(GameObject go, float duration, Vector3 scale, UnityAction finished = null)
        {
            TweenScale cls = TweenMain.Tween <TweenScale>(go, duration, finished);

            cls.from = cls.value;
            cls.to   = scale;
            cls.Start();
            return(cls);
        }
コード例 #5
0
        /// <summary>
        /// Create a TweenScale Component, and starts a tween.
        /// </summary>
        /// <param name="go">GameObject to Apply the tween too</param>
        /// <param name="duration">How long the tween will take</param>
        /// <param name="scale">The final Value at the end of the tween</param>
        /// <param name="method">The tweening method</parm>
        /// <param name="finished">The method execute at the end of the tween</param>
        /// <returns>Reference to the TweenScale component</returns>
        public static TweenScale Tween(GameObject go, float duration, Vector3 scale,
                                       Style style = Style.Once, Method method = Method.Linear, UnityAction finished = null, bool newObj = true)
        {
            TweenScale cls = TweenMain.Tween <TweenScale>(go, duration, style, method, finished, newObj);

            cls.from = cls.value;
            cls.to   = scale;
            cls.Start();
            return(cls);
        }
コード例 #6
0
ファイル: TweenRot.cs プロジェクト: zeya-anwar/UnicornBattle
        /// <summary>
        /// Create a TweenRot Component and start a tween
        /// </summary>
        /// <param name="go">GameObject to apply tween too</param>
        /// <param name="duration">Duration of tween</param>
        /// <param name="fromVal">The starting value for the tween</param>
        /// <param name="toVal">The ending value for the tween</param>
        /// <param name="style">The style of tween (Once, Looped, PingPong)</param>
        /// <param name="method">The Interpolation method of the tween</param>
        /// <param name="finished">A optional Callback to fire when the tween is done</param>
        /// <returns>Return reference to the new TweenRot component</returns>
        public static TweenRot Tween(GameObject go, float duration, Quaternion fromVal, Quaternion toVal,
                                     Style style, Method method, UnityAction finished = null)
        {
            TweenRot cls = TweenMain.Tween <TweenRot>(go, duration, style, method, finished);

            cls.from = fromVal.eulerAngles;
            cls.to   = toVal.eulerAngles;
            cls.Start();
            return(cls);
        }
コード例 #7
0
ファイル: TweenAlpha.cs プロジェクト: CyberSys/Mugen3D
        /// <summary>
        /// Create a TweenAlpha Component, and starts a tween.
        /// </summary>
        /// <param name="go">GameObject to Apply the tween too</param>
        /// <param name="duration">How long the tween will take</param>
        /// <param name="alpha">The final Value at the end of the tween</param>
        /// <param name="method">The tweening method</parm>
        /// <param name="finished">The method execute at the end of the tween</param>
        /// <returns>Reference to the TweenAlpha component</returns>
        public static TweenAlpha Tween(GameObject go, float duration, float alpha,
                                       Style style = Style.Once, Method method = Method.Linear, UnityAction finished = null)
        {
            TweenAlpha cls = TweenMain.Tween <TweenAlpha>(go, duration, style, method, finished);

            cls.from = cls.value;
            cls.to   = alpha;
            cls.Start();
            return(cls);
        }
コード例 #8
0
        /// <summary>
        /// Create a TweenRot Component, and starts a tween.
        /// </summary>
        /// <param name="go">GameObject to Apply the tween too</param>
        /// <param name="duration">How long the tween will take</param>
        /// <param name="rot">The Fianl Value at the end of the tween</param>
        /// <param name="method">The tweening method</parm>
        /// <param name="finished">The method execute at the end of the tween</param>
        /// <returns>Reference to the TweenRot component</returns>
        static public TweenRot Tween(GameObject go, float duration, Quaternion rot,
                                     Style style = Style.Once, Method method = Method.Linear, UnityAction finished = null, bool newObj = true)
        {
            TweenRot cls = TweenMain.Tween <TweenRot>(go, duration, style, method, finished, newObj);

            cls.from = cls.value.eulerAngles;
            cls.to   = rot.eulerAngles;
            cls.Start();
            return(cls);
        }
コード例 #9
0
ファイル: TweenPos.cs プロジェクト: CyberSys/Mugen3D
        /// <summary>
        /// Create a TweenPos Component, and starts a tween.
        /// </summary>
        /// <param name="go">GameObject to Apply the tween too</param>
        /// <param name="duration">How long the tween will take</param>
        /// <param name="pos">The final Value at the end of the tween</param>
        /// <param name="Style">The tweening style</parm>
        /// <param name="method">The tweening method</parm>
        /// <param name="finished">The method execute at the end of the tween</param>
        /// <returns>Reference to the TweenPos component</returns>
        public static TweenPos Tween(GameObject go, float duration, Vector3 pos,
                                     Style style = Style.Once, Method method = Method.Linear, UnityAction finished = null)
        {
            TweenPos cls = TweenMain.Tween <TweenPos>(go, duration, style, method, finished);

            cls.from = cls.value;
            cls.to   = pos;
            cls.Start();
            return(cls);
        }
コード例 #10
0
        /// <summary>
        /// Create a TweenSlider Component and start a tween
        /// </summary>
        /// <param name="go">GameObject to apply tween to</param>
        /// <param name="duration">Duration of tween</param>
        /// <param name="fromVal">The starting value for the tween</param>
        /// <param name="toVal">The ending value for the tween</param>
        /// <param name="style">The style of tween (Once, Looped, PingPong)</param>
        /// <param name="method">The Interpolation method of the tween</param>
        /// <param name="finished">A optional callback to fire when the tween is done</param>
        /// <returns>Returns a reference to the new TweenAlpha component</returns>
        public static TweenSlider Tween(GameObject go, float duration, float fromVal, float toVal,
                                        Style style, Method method, UnityAction finished = null)
        {
            TweenSlider cls = TweenMain.Tween <TweenSlider>(go, duration, style, method, finished);

            cls.from = fromVal;
            cls.to   = toVal;
            cls.Start();
            return(cls);
        }
コード例 #11
0
        /// <summary>
        /// Create a TweenPos Component and start a tween
        /// </summary>
        /// <param name="go">GameObject to apply tween too</param>
        /// <param name="duration">Duration of tween</param>
        /// <param name="pos">The ending value for the tween</param>
        /// <param name="finished">A optional Callback to fire when the tween is done</param>
        /// <param name="cSpace">A optional Arugmeant to define the coordnaite space to work in</param>
        /// <returns>Return reference to the new TweenPos component</returns>
        public static TweenPos Tween(GameObject go, float duration, Vector3 pos, UnityAction finished = null, CSpace cSpace = CSpace.Anchored)
        {
            TweenPos cls = TweenMain.Tween <TweenPos>(go, duration, finished);

            cls.CSpace = cSpace;
            cls.from   = cls.value;
            cls.to     = pos;
            cls.Start();
            return(cls);
        }
コード例 #12
0
        /// <summary>
        /// Create a TweenPos Component and start a tween
        /// </summary>
        /// <param name="go">GameObject to apply tween too</param>
        /// <param name="duration">Duration of tween</param>
        /// <param name="fromVal">The starting value for the tween</param>
        /// <param name="toVal">The ending value for the tween</param>
        /// <param name="style">The style of tween (Once, Looped, PingPong)</param>
        /// <param name="method">The Interpolation method of the tween</param>
        /// <param name="finished">A optional Callback to fire when the tween is done</param>
        /// <param name="cSpace">A optional Arugmeant to define the coordnaite space to work in</param>
        /// <returns>Return reference to the new TweenPos component</returns>
        public static TweenPos Tween(GameObject go, float duration, Vector3 fromVal, Vector3 toVal,
                                     Style style, Method method, UnityAction finished = null, CSpace cSpace = CSpace.Anchored)
        {
            TweenPos cls = TweenMain.Tween <TweenPos>(go, duration, style, method, finished);

            cls.CSpace = cSpace;
            cls.from   = fromVal;
            cls.to     = toVal;
            cls.Start();
            return(cls);
        }
コード例 #13
0
ファイル: TweenMain.cs プロジェクト: 737871854/FireMen2
        void Update()
        {
            float delta = ignoreTimeScale ? UnScaledTime.deltaTime : Time.deltaTime;
            float time  = ignoreTimeScale ? UnScaledTime.time : Time.time;

            if (!_Started)
            {
                _Started   = true;
                _StartTime = time + delay;
            }

            if (time < _StartTime)
            {
                return;
            }

            _Factor += amountPerDelta * delta;

            if (style == Style.Loop)
            {
                if (_Factor > 1f)
                {
                    _Factor -= Mathf.Floor(_Factor);
                }
            }
            else if (style == Style.PingPong)
            {
                if (_Factor > 1f)
                {
                    _Factor         = 1f - (_Factor - Mathf.Floor(_Factor));
                    _AmountPerDelta = -_AmountPerDelta;
                }
                else if (_Factor < 0f)
                {
                    _Factor         = -_Factor;
                    _Factor        -= Mathf.Floor(_Factor);
                    _AmountPerDelta = -_AmountPerDelta;
                }
            }

            if ((style == Style.Once) && (duration == 0f || _Factor > 1f || _Factor < 0f))
            {
                _Factor = Mathf.Clamp01(_Factor);
                Sample(_Factor, true);

                if (duration == 0f || (_Factor == 1f && _AmountPerDelta > 0f || _Factor == 0f && amountPerDelta < 0f))
                {
                    enabled = false;
                }

                //Event Callback stuff
                if (self == null)
                {
                    self = this;
                    if (OnFinished != null)
                    {
                        OnFinished.Invoke();
                    }
                }
                self = null;
            }
            else
            {
                Sample(_Factor, false);
            }
        }