internal static QuaternionTween GetQuaternionTween(Quaternion from, Quaternion to, float t) { QuaternionTween tween; if (TryGetTween(quaternionTweens, out tween)) { tween.Init(from, to, t); } else { tween = new QuaternionTween(from, to, t, GenerateId()); tween.Recycle = FinishTween; } _activeTweens.Add(tween); return(tween); }
public static QuaternionTween TweenRotation(this Transform obj, float duration, Quaternion from, Quaternion to, bool relativeWorld = false) { QuaternionTween node = QuaternionTween.Allocate(duration, from, to); node.SetUpdate( (result) => { if (relativeWorld) { obj.rotation = result; } else { obj.localRotation = result; } }); return(node); }
public BaseTween RotateTween(Transform t, Quaternion to, float time) { QuaternionTween tween = TweenPool.GetQuaternionTween(t.rotation, to, time); tween.SetOnUpdateQuaternion(delegate(Quaternion v) { if (t != null) { t.rotation = v; } else { CancelTween(tween); } }); return(ProcessTween(tween)); }
public static PTween createTween <T>() where T : struct { PTween tween = null; Type t = typeof(T); if (t == typeof(int)) { tween = new IntTween(); } else if (t == typeof(float)) { tween = new FloatTween(); } else if (t == typeof(Vector2)) { tween = new Vector2Tween(); } else if (t == typeof(Vector3)) { tween = new Vector3Tween(); } else if (t == typeof(Vector4)) { tween = new Vector4Tween(); } else if (t == typeof(Color)) { tween = new ColorTween(); } else if (t == typeof(Quaternion)) { tween = new QuaternionTween(); } else { Debug.LogError("PTween createTween: invalid type: " + t); return(null); } add(tween); return(tween); }
/// <summary> /// transform.localRotation tween /// </summary> /// <returns>The klocal rotation to.</returns> /// <param name="self">Self.</param> /// <param name="to">To.</param> /// <param name="duration">Duration.</param> public static ITween<Quaternion> ZKlocalRotationTo( this Transform self, Quaternion to, float duration = 0.3f ) { var tweenTarget = new TransformRotationTarget( self, TransformRotationTarget.TransformRotationType.LocalRotation ); var tween = new QuaternionTween( tweenTarget, self.localRotation, to, duration ); return tween; }