Example #1
0
        public static IEnumerator ToVector3Coroutine(
            Vector3 vector3,
            Vector3 targetVector3,
            float speedMultiplier,
            CurveAsset curveAsset,
            Action <Vector3> step,
            Action <Vector3> finished)
        {
            Vector3 startVector3 = vector3;
            float   time         = 0;

            while (time < 1)
            {
                time += Time.deltaTime * speedMultiplier;
                float easedTime = time;
                if (null != curveAsset)
                {
                    easedTime = curveAsset.Curve.Evaluate(time);
                }
                vector3 = Vector3.Lerp(startVector3, targetVector3, easedTime);
                if (null != step)
                {
                    step(vector3);
                }
                yield return(null);
            }

            vector3 = targetVector3;
            if (null != finished)
            {
                finished(vector3);
            }
        }
Example #2
0
 public static Coroutine ToPosition(
     MonoBehaviour monoBehaviour,
     Transform transform,
     Vector3 targetPosition,
     float speedMultiplier,
     CurveAsset easeCurve,
     Action <Transform> step,
     Action <Transform> finished)
 {
     return(monoBehaviour.StartCoroutine(
                Vector3TweenUtility.ToVector3Coroutine(
                    transform.position,
                    targetPosition,
                    speedMultiplier,
                    easeCurve,
                    vector3 =>
     {
         transform.position = vector3;
         Debug.DrawRay(transform.position, Vector3.up * 100, Color.cyan);
         if (null != step)
         {
             step(transform);
         }
     },
                    vector3 =>
     {
         transform.position = vector3;
         Debug.DrawRay(transform.position, Vector3.up * 100, Color.red);
         if (null != finished)
         {
             finished(transform);
         }
     })
                ));
 }
Example #3
0
 public static Coroutine ToLocalPosition(
     MonoBehaviour monoBehaviour,
     Transform transform,
     Vector3 targetPosition,
     float speedMultiplier,
     CurveAsset easeCurve,
     Action <Transform> step,
     Action <Transform> finished)
 {
     return(monoBehaviour.StartCoroutine(
                Vector3TweenUtility.ToVector3Coroutine(
                    transform.localPosition,
                    targetPosition,
                    speedMultiplier,
                    easeCurve,
                    vector3 =>
     {
         transform.localPosition = vector3;
         if (null != step)
         {
             step(transform);
         }
     },
                    vector3 =>
     {
         transform.localPosition = vector3;
         if (null != finished)
         {
             finished(transform);
         }
     })
                ));
 }
Example #4
0
        public VolumeMixer(CurveAsset fadeout, CurveAsset fadein, float transitionDelay)
        {
            this.m_FadeOutCurve = fadeout.GetReusableCurve();
            this.m_FadeInCurve  = fadein.GetReusableCurve();

            this.transitionDelay = transitionDelay;
        }
Example #5
0
 /// <summary>
 /// Extension method to start a curve's Run routine on a given MonoBehaviour if it is not already active
 /// isActive is set true before evaluation and set false afterward
 /// </summary>
 /// <access>public static void</access>
 /// <param name="behaviour" type="this MonoBehaviour">The behaviour to start the routine on</param>
 /// <param name="curve" type="CurveAsset">The curve to get the routine from</param>
 /// <param name="callback" type="Action(float)">Callback action that takes an input float value</param>
 /// <param name="isActive" type="Reference<bool>"Is the curve already being run?</param>
 /// <seealso cref="CurveAsset.Run(Action{float})" />
 public static void RunCurve(this MonoBehaviour behaviour, CurveAsset curve, Action <float> callback, Reference <bool> isActive)
 {
     if (isActive)
     {
         return;
     }
     behaviour.StartCoroutine(curve.Run(callback, () => isActive.Set(true), () => isActive.Set(false)));
 }
Example #6
0
 /// <summary>
 /// Extension method to start a curve's Run routine on a given MonoBehaviour if it is not already active
 /// isActive is set true before calling onStart and set false after calling onEnd
 /// </summary>
 /// <access>public static void</access>
 /// <param name="behaviour" type="this MonoBehaviour">The behaviour to start the routine on</param>
 /// <param name="curve" type="CurveAsset">The curve to get the routine from</param>
 /// <param name="duration" type="float">Inverse scale factor for input time</param>
 /// <param name="scale" type="float">Scale factor for curve value</param>
 /// <param name="callback" type="Action(float)">Callback action that takes an input float value</param>
 /// <param name="onStart" type="Action()">Action run before curve evaluation begins</param>
 /// <param name="onEnd" type="Action()">Action run after curve evaluation finishes</param>
 /// <param name="isActive" type="Reference<bool>"Is the curve already being run?</param>
 /// <seealso cref="CurveAsset.Run(float, float, Action{float}, Action, Action)" />
 public static void RunCurve(this MonoBehaviour behaviour, CurveAsset curve, float duration, float scale, Action <float> callback, Action onStart, Action onEnd, Reference <bool> isActive)
 {
     if (isActive)
     {
         return;
     }
     behaviour.StartCoroutine(curve.Run(duration, scale, callback, () => { isActive.Set(true); onStart(); }, () => { onEnd(); isActive.Set(false); }));
 }
 public void ToLocalPosition(
     float x, float y, float z,
     float speedMultiplier       = 0,
     CurveAsset easeCurve        = null,
     Action <Transform> step     = null,
     Action <Transform> finished = null)
 {
     ToLocalPosition(new Vector3(x, y, z), speedMultiplier, easeCurve, step, finished);
 }
 public void TweenToPosition(
     Vector3 target,
     float speedMultiplier       = 0,
     CurveAsset easeCurve        = null,
     Action <Transform> step     = null,
     Action <Transform> finished = null)
 {
     GetComponent <TransformTweener>().ToPosition(target, speedMultiplier, easeCurve, step, finished);
 }
Example #9
0
 public void SetAnimation(CurveAsset asset)
 {
     this.Animation0.Curve = asset.FindCurve("FAC0");
     this.Animation0.Time  = 0.0f;
     this.Animation0.Speed = 1f;
     this.Animation1.Curve = asset.FindCurve("FAC1");
     this.Animation1.Time  = 0.0f;
     this.Animation1.Speed = 1f;
     this.PlayAnimation    = true;
 }
Example #10
0
        public static VolumeMixer CreateVolumeMixer(float transitionTime = 0.0f)
        {
            //Debug.Log($"Path:{mixerAssetPath}/{fadeInAsset}");

            if (fadeInData == null)
            {
                fadeInData = Resources.Load <CurveAsset>($"{mixerAssetPath}/{fadeInAsset}");
            }
            if (fadeOutData == null)
            {
                fadeOutData = Resources.Load <CurveAsset>($"{mixerAssetPath}/{fadeOutAsset}");
            }

            return(new VolumeMixer(fadeOutData, fadeInData, transitionTime));
        }
 public void ToPosition(
     Vector3 target,
     float speedMultiplier       = 0,
     CurveAsset easeCurve        = null,
     Action <Transform> step     = null,
     Action <Transform> finished = null)
 {
     StopPositionCoroutine();
     _positionCoroutine = TransformTweenUtility.ToPosition(
         this,
         transform,
         target,
         Mathf.Approximately(speedMultiplier, 0) ? _speedMultiplier : speedMultiplier,
         easeCurve == null ? _easeCurve : easeCurve,
         step,
         finished);
 }
Example #12
0
 /// <summary>
 /// Extension method to start a curve's Run routine on a given MonoBehaviour
 /// </summary>
 /// <access>public static void</access>
 /// <param name="behaviour" type="this MonoBehaviour">The behaviour to start the routine on</param>
 /// <param name="curve" type="CurveAsset">The curve to get the routine from</param>
 /// <param name="callback" type="Action(float)">Callback action that takes an input float value</param>
 /// <seealso cref="CurveAsset.Run(Action{float})" />
 public static Coroutine RunCurve(this MonoBehaviour behaviour, CurveAsset curve, Action <float> callback)
 {
     return(behaviour.StartCoroutine(curve.Run(callback)));
 }
Example #13
0
 /// <summary>
 /// Extension method to start a curve's Run routine on a given MonoBehaviour
 /// </summary>
 /// <access>public static void</access>
 /// <param name="behaviour" type="this MonoBehaviour">The behaviour to start the routine on</param>
 /// <param name="curve" type="CurveAsset">The curve to get the routine from</param>
 /// <param name="callback" type="Action(float)">Callback action that takes an input float value</param>
 /// <param name="onStart" type="Action()">Action run before curve evaluation begins</param>
 /// <param name="onEnd" type="Action()">Action run after curve evaluation finishes</param>
 /// <seealso cref="CurveAsset.Run(Action{float}, Action, Action)" />
 public static void RunCurve(this MonoBehaviour behaviour, CurveAsset curve, Action <float> callback, Action onStart, Action onEnd)
 {
     behaviour.StartCoroutine(curve.Run(callback, onStart, onEnd));
 }
Example #14
0
 /// <summary>
 /// Extension method to start a curve's Run routine on a given MonoBehaviour
 /// </summary>
 /// <access>public static void</access>
 /// <param name="behaviour" type="this MonoBehaviour">The behaviour to start the routine on</param>
 /// <param name="curve" type="CurveAsset">The curve to get the routine from</param>
 /// <param name="duration" type="float">Inverse scale factor for input time</param>
 /// <param name="scale" type="float">Scale factor for curve value</param>
 /// <param name="callback" type="Action(float)">Callback action that takes an input float value</param>
 /// <seealso cref="CurveAsset.Run(float, float, Action{float})" />
 public static void RunCurve(this MonoBehaviour behaviour, CurveAsset curve, float duration, float scale, Action <float> callback)
 {
     behaviour.StartCoroutine(curve.Run(duration, scale, callback));
 }