static void MoveTo(GameObject target, Vector3[] nodes, float time, EaseType easyType, bool firstNode, string updateFuncName, string complateFuncName, GameObject funcTarget, object param) { if( null != target && firstNode && null != nodes && nodes.Length > 0 ) { target.transform.localPosition = nodes[0]; } Hashtable args = iTween.Hash("path", nodes, "time", time, "easetype", easyType.ToString()); if(null != updateFuncName) { args["onupdate"] = updateFuncName; if(null != param) { args["onupdateparams"] = param; } if(null != funcTarget) args["onupdatetarget"] = funcTarget; } if(null != complateFuncName) { args["oncomplete"] = complateFuncName; if(null != param) { args["oncompleteparams"] = param; } if(null != funcTarget) args["oncompletetarget"] = funcTarget; } iTween.MoveTo(target, args); }
public override string ToString() { return($"Tween ({GetType().Name})\n" + (Speed > 0 ? $"Speed: {Speed}\n" : $"Duration: {Duration}\n") + $"Delta Time: {DeltaTimeType}\n" + $"Ease Type: {(CustomEase != null ? "Custom Ease" : EaseType.ToString())}\n" + $"Loop: {LoopType.ToString()} {(LoopType != LoopType.None ? "(Amount: " + (LoopAmount < 1 ? "Infinite" : LoopAmount.ToString()) + ")" : string.Empty)}\n" + $"Callbacks: {(onInitialize != null ? "OnInitialize " : string.Empty)} {(onUpdate != null ? "OnUpdate " : string.Empty)} {(onCompleted != null ? "OnCompleted " : string.Empty)} {(onStepCompleted != null ? "OnLoopStepCompleted " : string.Empty)}"); }
/// <summary> /// Provides an ease-in factor for the given animation progress. /// </summary> /// <param name="progress"> The fractional progress of the animation (from 0 to 1). </param> /// <param name="type"> The type of easing to perform. </param> /// <returns> The factor to use in the animation. </returns> public static double InFactor(double progress, EaseType type) { switch (type) { case EaseType.Linear: return progress; case EaseType.Quadratic: return progress * progress; case EaseType.Cubic: return progress * progress * progress; } throw new NotImplementedException("Don't know how to ease in for " + type.ToString()); }
private void OnDrawGizmos() { Gizmos.color = Color.blue; var vect = Vector3.zero; var cache = Vector3.zero; var beginX = transform.position.x; var beginY = transform.position.y; cache.x = beginX; cache.y = beginY; var height = 0.5f; var total = 1f; for (var t = 0.01f; t <= 1.01f;) { var calc = Ease.Eval(type, t, total, beginY, beginY + height); vect.x = t + beginX; vect.y = calc; Gizmos.DrawLine(cache, vect); cache = vect; t += 0.01f; } UnityEditor.Handles.Label(transform.position, type.ToString()); Gizmos.color = Color.black; cache = transform.position; cache.x += 1f; Gizmos.DrawLine(transform.position, cache); cache = transform.position; cache.y += height; Gizmos.DrawLine(transform.position, cache); vect = transform.position; vect.x += 1f; cache = transform.position; cache.x += 1f; cache.y += height; Gizmos.DrawLine(vect, cache); vect = transform.position; vect.y += height; cache = transform.position; cache.x += 1f; cache.y += height; Gizmos.DrawLine(vect, cache); }
private static OperationalStructBase <T> Easing <T>(float time, OperationalStructBase <T> initial, OperationalStructBase <T> delta, float duration, EaseType easeType) where T : struct { if (!EasingFunctions <T> .EasingFunctionMap.ContainsKey(easeType)) { throw new ArgumentException($"EaseType: '{easeType.ToString()}' does not implement yet."); } if (time <= 0.0f) { return(initial); } if (time >= duration) { return(initial + delta); } return(EasingFunctions <T> .EasingFunctionMap[easeType](time, initial, delta, duration)); }
/// <summary> /// Changes a GameObject's position over time to a supplied destination. /// </summary> /// <param name="position"> /// A <see cref="Vector3"/> /// </param> /// <param name="islocal"> /// A <see cref="bool"> /// </param> /// <param name="time"> /// A <see cref="System.Single"/> /// </param> /// <param name="delay"> /// A <see cref="System.Single"/> /// </param> /// <param name="easeType"> /// A <see cref="EaseType"/> /// </param> public static void MoveTo(this GameObject go,Vector3 position,bool islocal,float time,float delay,EaseType easeType){ iTween.MoveTo(go,iTween.Hash("position",position,"islocal",islocal,"time",time,"delay",delay,"easeType",easeType.ToString())); }
/// <summary> /// Adds the supplied coordinates to a GameObject's position. /// </summary> /// <param name="amount"> /// A <see cref="Vector3"/> /// </param> /// <param name="time"> /// A <see cref="System.Single"/> /// </param> /// <param name="delay"> /// A <see cref="System.Single"/> /// </param> /// <param name="easeType"> /// A <see cref="EaseType"/> /// </param> public static void MoveBy(this GameObject go,Vector3 amount,float time,float delay,EaseType easeType){ iTween.MoveBy(go,iTween.Hash("amount",amount,"time",time,"delay",delay,"easeType",easeType.ToString())); }
/// <summary> /// Rotates a GameObject to look at the supplied Vector3 over time. /// </summary> /// <param name="lookTarget"> /// A <see cref="Vector3"/> /// </param> /// <param name="time"> /// A <see cref="System.Single"/> /// </param> /// <param name="delay"> /// A <see cref="System.Single"/> /// </param> /// <param name="easeType"> /// A <see cref="EaseType"/> /// </param> /// <param name="loopType"> /// A <see cref="LoopType"/> /// </param> public static void LookTo(this GameObject go,Vector3 lookTarget,float time,float delay,EaseType easeType,LoopType loopType){ iTween.LookTo(go,iTween.Hash("lookTarget",lookTarget,"time",time,"delay",delay,"easeType",easeType.ToString(),"looptype",loopType.ToString())); }
/// <summary> /// Changes a GameObject's scale over time. /// </summary> /// <param name="scale"> /// A <see cref="Vector3"/> /// </param> /// <param name="time"> /// A <see cref="System.Single"/> /// </param> /// <param name="delay"> /// A <see cref="System.Single"/> /// </param> /// <param name="easeType"> /// A <see cref="EaseType"/> /// </param> /// <param name="loopType"> /// A <see cref="LoopType"/> /// </param> public static void ScaleTo(this GameObject go,Vector3 scale,float time,float delay,EaseType easeType,LoopType loopType){ iTween.ScaleTo(go,iTween.Hash("scale",scale,"time",time,"delay",delay,"easeType",easeType.ToString(),"looptype",loopType.ToString())); }
/// <summary> /// Rotates a GameObject to the supplied Euler angles in degrees over time. /// </summary> /// <param name="amount"> /// A <see cref="Vector3"/> /// </param> /// <param name="time"> /// A <see cref="System.Single"/> /// </param> /// <param name="delay"> /// A <see cref="System.Single"/> /// </param> /// <param name="easeType"> /// A <see cref="EaseType"/> /// </param> public static void RotateTo(this GameObject go,Vector3 rotation,float time,float delay,EaseType easeType){ iTween.RotateTo(go,iTween.Hash("rotation",rotation,"time",time,"delay",delay,"easeType",easeType.ToString())); }
public static void MoveTo(this GameObject go, Vector3 position, float time, string OnComplete, GameObject onCompleteTarget, float delay = 0, EaseType easeType = EaseType.linear) { iTween.MoveTo(go, iTween.Hash("position", position, "time", time, "delay", delay, "easeType", easeType.ToString(), "oncompletetarget", onCompleteTarget, "oncomplete", OnComplete)); }
public void ScaleTo(Vector3 from, Vector3 to, float time, EaseType easeType = EaseType.linear) { transform.localScale = from; FinalVectorValue = to; SA_iTween.ScaleTo(gameObject, SA_iTween.Hash("scale", to, "time", time, "easeType", easeType.ToString(), "oncomplete", "onTweenComplete", "oncompletetarget", gameObject)); }
/// <summary> /// Changes a GameObject's position over time along a supplied path. /// </summary> /// <param name="go"> /// A <see cref="GameObject"/> /// </param> /// <param name="path"> /// A <see cref="Transform[]"/> /// </param> /// <param name="time"> /// A <see cref="System.Single"/> /// </param> /// <param name="delay"> /// A <see cref="System.Single"/> /// </param> /// <param name="easeType"> /// A <see cref="EaseType"/> /// </param> /// <param name="loopType"> /// A <see cref="LoopType"/> /// </param> public static void MoveTo(this GameObject go,Transform[] path,float time,float delay,EaseType easeType,LoopType loopType){ iTween.MoveTo(go,iTween.Hash("path",path,"time",time,"delay",delay,"easeType",easeType.ToString(),"looptype",loopType.ToString())); }
/// <summary> /// Apply an ease to a interpolation value from zero to one /// </summary> /// <param name="easeType">The easing type to use - In, Out or InOut</param> /// <param name="power">The easing power to use (2 for quadratic, 3 for cubic, etc)</param> /// <param name="t">The interpolation parameter to apply easing to</param> /// <returns>An eased version of the interpolation parameter t</returns> public static float Transform(EaseType easeType, int power, float t) { switch (easeType) { case EaseType.In: return(In(power, t)); case EaseType.Out: return(Out(power, t)); case EaseType.InOut: return(InOut(power, t)); default: throw new System.FormatException("Unexpected value provided for EaseType: " + easeType.ToString()); } }
public static void MoveTo(this GameObject go,Vector3 position,float time, float delay,EaseType easeType, string onCompleteCall, GameObject onCompleteGO, Vector3 onCompleteParams) { iTween.MoveTo(go,iTween.Hash("position",position,"time",time,"delay",delay,"easeType",easeType.ToString(), "oncomplete", onCompleteCall, "oncompletetarget", onCompleteGO,"oncompleteparams", onCompleteParams)); }
/// <summary> /// nantas override iTween functions public static void MoveTo(this GameObject go,Vector3[] path,float time,float delay, EaseType easeType, string onCompleteCall, GameObject onCompleteGO) { iTween.MoveTo(go,iTween.Hash("path",path,"time",time,"delay",delay, "easeType", easeType.ToString(), "oncomplete", onCompleteCall, "oncompletetarget", onCompleteGO)); }
//nantas override moveby functions public static void MoveBy(this GameObject go,Vector3 amount,float time,float delay, EaseType easeType, string onCompleteCall, GameObject onCompleteGO, Object onCompleteParams ) { iTween.MoveBy(go,iTween.Hash("amount",amount,"time",time, "delay",delay, "easeType",easeType.ToString(),"oncomplete", onCompleteCall, "oncompletetarget", onCompleteGO, "oncompleteparams", onCompleteParams)); }
/// <summary> /// Changes a GameObject's position over time along a supplied path. /// </summary> /// <param name="path"> /// A <see cref="Vector3[]"/> /// </param> /// <param name="time"> /// A <see cref="System.Single"/> /// </param> /// <param name="delay"> /// A <see cref="System.Single"/> /// </param> /// <param name="easeType"> /// A <see cref="EaseType"/> /// </param> public static void MoveTo(this GameObject go,Vector3[] path,float time,float delay,EaseType easeType){ iTween.MoveTo(go,iTween.Hash("path",path,"time",time,"delay",delay,"easeType",easeType.ToString())); }
public void VectorToS(Vector3 from, Vector3 to, float speed, EaseType easeType = EaseType.linear) { transform.position = from; FinalVectorValue = to; SA_iTween.MoveTo(gameObject, SA_iTween.Hash("position", to, "speed", speed, "easeType", easeType.ToString(), "oncomplete", "onTweenComplete", "oncompletetarget", gameObject)); }
/// <summary> /// Changes a GameObject's position over time to a supplied destination. /// </summary> /// <param name="position"> /// A <see cref="Vector3"/> /// </param> /// <param name="time"> /// A <see cref="System.Single"/> /// </param> /// <param name="delay"> /// A <see cref="System.Single"/> /// </param> /// <param name="easeType"> /// A <see cref="EaseType"/> /// </param> /// <param name="loopType"> /// A <see cref="LoopType"/> /// </param> public static void MoveTo(this GameObject go,Vector3 position,float time,float delay,EaseType easeType,LoopType loopType){ iTween.MoveTo(go,iTween.Hash("position",position,"time",time,"delay",delay,"easeType",easeType.ToString(),"looptype",loopType.ToString())); }
/// <summary> /// Create a transition effect between cameras. /// /// At the end of the transition, the source camera (from) will be deactivated /// and the camera target (to) will be activated. /// /// No AudioListener is modified. /// </summary> /// <param name="transition">The transition effect.</param> /// <param name="from">Source camera.</param> /// <param name="to">Target camera.</param> /// <param name="time">Duration in seconds (>0).</param> /// <param name="parameters">Parameters to configure the effects (optional).</param> /// <remarks> /// Transitions parameters: /// <list type="bullet"> /// <item>Cube: perspective (float), zoom (float), reflection (float), elevation (float).</item> /// <item>Doom: bar width (int), amplitude (float), noise (float), frequency (float).</item> /// <item>FadeToColor: strength (float), color (Color).</item> /// <item>FadeToGrayscale: strength (float).</item> /// <item>Flash: strength (float), intensity (float), zoom (float), velocity (float), color (Color).</item> /// <item>Fold: mode (CameraTransitionFold.Modes).</item> /// <item>Flip: mode (CameraTransitionFlip.Modes).</item> /// <item>Gate: perspective (float), depth (float), reflection (float).</item> /// <item>Glitch: strength (float).</item> /// <item>LinearBlur: intensity (float), passes (int).</item> /// <item>Mosaic: steps (Vector2), rotate (bool).</item> /// <item>PageCurl: angle (float), radius (float), shadows (bool).</item> /// <item>PageCurlAdvanced: angle (float), radius (float).</item> /// <item>Pixelate: size (float).</item> /// <item>Radial: clockwise (bool).</item> /// <item>RandomGrid: rows (int), columns (int), smoothness (float).</item> /// <item>SmoothCircle: invert (bool), smoothness (float).</item> /// <item>SmoothLine: angle (float), smoothness (float).</item> /// <item>Swap: perspective (float), depth (float), reflection (float).</item> /// <item>Valentine: border (float), color (Color).</item> /// <item>WarpWave: mode (CameraTransitionWarpWave.Modes), curvature (float).</item> /// </list> /// <example> /// cameraTransition.DoTransition(CameraTransitionEffects.FadeToColor, cameraA, cameraB, 1.0f, new object[] { 0.3f, Color.black }); /// </example> /// </remarks> public void DoTransition(CameraTransitionEffects transition, Camera from, Camera to, float time, params object[] parameters) { if (from != null && to != null) { if (from != to) { if (time > 0.0f) { isRunning = true; Progress = 0.0f; Transition = transition; FromCamera = from; ToCamera = to; transitionTime = time; transitionLife = 0.0f; from.gameObject.SetActive(false); to.gameObject.SetActive(true); from.gameObject.SetActive(true); currentEffect.InvertRenderTexture = invertRenderTexture; #if ENABLE_LOGS Debug.LogFormat("Camera transition '{0}' from '{1}' to '{2}' using '{3}' in {4} seconds.", transition.ToString(), from.gameObject.name, to.gameObject.name, easeType.ToString(), time); #endif if (parameters != null && parameters.Length > 0) { SetParametersToCurrentEffect(parameters); } StartCoroutine(TransitionCoroutine()); } else { Debug.LogWarning(@"Duration must be greater than zero."); } } else { Debug.LogWarning(@"Cameras must be differents."); } } else { Debug.LogWarning(@"Invalid cameras."); } }
/// <summary> /// Adds supplied Euler angles in degrees to a GameObject's rotation over time. /// </summary> /// <param name="amount"> /// A <see cref="Vector3"/> /// </param> /// <param name="time"> /// A <see cref="System.Single"/> /// </param> /// <param name="delay"> /// A <see cref="System.Single"/> /// </param> /// <param name="easetype"> /// A <see cref="EaseType"/> /// </param> /// <param name="looptype"> /// A <see cref="LoopType"/> /// </param> public static void RotateAdd(this GameObject go,Vector3 amount,float time,float delay,EaseType easeType,LoopType loopType){ iTween.RotateAdd(go,iTween.Hash("amount",amount,"time",time,"delay",delay,"easeType",easeType.ToString(),"looptype",loopType.ToString())); }
public void ValueTo(float from, float to, float time, EaseType easeType = EaseType.linear) { Vector3 pos = transform.position; pos.x = from; transform.position = pos; FinalFloatValue = to; SA_iTween.MoveTo(gameObject, SA_iTween.Hash("x", to, "time", time, "easeType", easeType.ToString(), "oncomplete", "onTweenComplete", "oncompletetarget", gameObject)); }