示例#1
0
 public static Coroutine Tween(UnityAction <Vector4> onChange, Vector4 from, Vector4 to, float duration,
                               AnimationCurve curve = null, bool ignoreTimeScale = false, UnityObject parent = null)
 {
     if (curve == null)
     {
         curve = defaultCurve;
     }
     return(CoroutineHolder.StartCoroutine(parent, TweenCustomRoute(
                                               onChange, from, to, duration, curve, ignoreTimeScale
                                               )));
 }
示例#2
0
        public static Coroutine Tween(this Transform target, Transform from, Transform to,
                                      float duration, AnimationCurve curve = null,
                                      bool position = true, bool rotation = true, bool scale = true, bool ignoreTimeScale = false)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (to == null)
            {
                throw new ArgumentNullException("to");
            }
            if (curve == null)
            {
                curve = defaultCurve;
            }
            Coroutine c;

            if (position && tPosDict.TryGetValue(target, out c))
            {
                CoroutineHolder.FindAndStopCoroutine(c);
            }
            if (rotation && tRotDict.TryGetValue(target, out c))
            {
                CoroutineHolder.FindAndStopCoroutine(c);
            }
            if (scale && tSclDict.TryGetValue(target, out c))
            {
                CoroutineHolder.FindAndStopCoroutine(c);
            }
            c = CoroutineHolder.StartCoroutine(target, TweenRoute(
                                                   target, from, to, duration, curve, position, rotation, scale, ignoreTimeScale
                                                   ));
            if (position)
            {
                tPosDict[target] = c;
            }
            if (rotation)
            {
                tRotDict[target] = c;
            }
            if (scale)
            {
                tSclDict[target] = c;
            }
            return(c);
        }
示例#3
0
        /// <summary>
        /// Find and stop the coroutine in all created holder instances.
        /// </summary>
        /// <param name="route">The route that have to stop</param>
        /// <returns><c>true</c> if success find the coroutine and stops it.</returns>
        public static bool FindAndStopCoroutine(IEnumerator route)
        {
            if (route == null)
            {
                return(false);
            }
            var _holders = new CoroutineHolder[holders.Count];

            holders.CopyTo(_holders);
            foreach (var holder in _holders)
            {
                if (holder != null && holder.StopCoroutine(route))
                {
                    return(true);
                }
            }
            return(false);
        }
示例#4
0
        public static Coroutine TweenRotation(this Transform target, Quaternion from, Quaternion to,
                                              float duration, AnimationCurve curve = null, bool ignoreTimeScale = false, bool local = false)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (curve == null)
            {
                curve = defaultCurve;
            }
            Coroutine c;

            if (tRotDict.TryGetValue(target, out c))
            {
                CoroutineHolder.FindAndStopCoroutine(c);
            }
            c = CoroutineHolder.StartCoroutine(target, TweenRotationRoute(
                                                   target, from, to, duration, curve, ignoreTimeScale, local
                                                   ));
            tRotDict[target] = c;
            return(c);
        }
示例#5
0
 public static Coroutine SetInterval(this UnityObject source, float delay, UnityAction action)
 {
     return(CoroutineHolder.SetInterval(source, delay, action));
 }
示例#6
0
 public static Coroutine Delay(this UnityObject source, float delay, UnityAction action)
 {
     return(CoroutineHolder.Delay(source, delay, action));
 }