/// <summary>Tweens an AudioSource's pitch to the given value. /// Also stores the AudioSource as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> public static TweenerCore <float, float, FloatOptions> DOPitch(this AudioSource target, float endValue, float duration) { TweenerCore <float, float, FloatOptions> t = DOTween.To(() => target.pitch, x => target.pitch = x, endValue, duration); t.SetTarget(target); return(t); }
/// <summary>Tweens a Text's color to the given value. /// Also stores the Text as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> public static TweenerCore <Color, Color, ColorOptions> DOColor(this Text target, Color endValue, float duration) { TweenerCore <Color, Color, ColorOptions> t = DOTween.To(() => target.color, x => target.color = x, endValue, duration); t.SetTarget(target); return(t); }
/// <summary>Tweens a Transform's localRotation to the given value. /// Also stores the transform as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> /// <param name="mode">Rotation mode</param> public static Tweener DOLocalRotate(this Transform target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast) { TweenerCore <Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.localRotation, x => target.localRotation = x, endValue, duration); t.SetTarget(target); t.plugOptions.rotateMode = mode; return(t); }
/// <summary>Tweens a CanvasGroup's alpha color to the given value. /// Also stores the canvasGroup as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> public static TweenerCore <float, float, FloatOptions> DOFade(this CanvasGroup target, float endValue, float duration) { TweenerCore <float, float, FloatOptions> t = DOTween.To(() => target.alpha, x => target.alpha = x, endValue, duration); t.SetTarget(target); return(t); }
/// <summary>Tweens an Image's alpha color to the given value. /// Also stores the image as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> public static TweenerCore <Color, Color, ColorOptions> DOFade(this Image target, float endValue, float duration) { TweenerCore <Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration); t.SetTarget(target); return(t); }
/// <summary>Tweens a Rigidbody2D's rotation to the given value. /// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> public static TweenerCore <float, float, FloatOptions> DORotate(this Rigidbody2D target, float endValue, float duration) { TweenerCore <float, float, FloatOptions> t = DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration); t.SetTarget(target); return(t); }
/// <summary>Tweens a Rigidbody's rotation to the given value. /// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> /// <param name="mode">Rotation mode</param> public static TweenerCore <Quaternion, Vector3, QuaternionOptions> DORotate(this Rigidbody target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast) { TweenerCore <Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, target.MoveRotation, endValue, duration); t.SetTarget(target); t.plugOptions.rotateMode = mode; return(t); }
/// <summary>Tweens a TextMeshPro's glow color to the given value. /// Also stores the TextMeshPro as the tween's inTarget so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> /// <param name="useSharedMaterial">If TRUE will use the fontSharedMaterial instead than the fontMaterial</param> public static TweenerCore <Color, Color, ColorOptions> DOGlowColor(this TMP_Text inTarget, Color endValue, float duration, bool useSharedMaterial = false) { TweenerCore <Color, Color, ColorOptions> t = useSharedMaterial ? inTarget.fontSharedMaterial.DOColor(endValue, "_GlowColor", duration) : inTarget.fontMaterial.DOColor(endValue, "_GlowColor", duration); t.SetTarget(inTarget); return(t); }
public static Tweener DORotateQuaternion(this Transform target, Quaternion endValue, float duration) { TweenerCore <Quaternion, Quaternion, NoOptions> t = DOTween.To <Quaternion, Quaternion, NoOptions>(PureQuaternionPlugin.Plug(), () => target.rotation, delegate(Quaternion x) { target.rotation = x; }, endValue, duration); t.SetTarget <TweenerCore <Quaternion, Quaternion, NoOptions> >(target); return(t); }
/// <summary>Tweens a TextMeshPro's scale to the given value (using correct uniform scale as TMP requires). /// Also stores the TextMeshPro as the tween's inTarget so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> public static TweenerCore <Vector3, Vector3, VectorOptions> DOScale(this TMP_Text inTarget, float endValue, float duration) { Transform trans = inTarget.transform; Vector3 endValueV3 = new Vector3(endValue, endValue, endValue); TweenerCore <Vector3, Vector3, VectorOptions> t = DOTween.To(() => trans.localScale, x => trans.localScale = x, endValueV3, duration); t.SetTarget(inTarget); return(t); }
/// <summary>Tweens a RectTransform's pivot to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> public static TweenerCore <Vector2, Vector2, VectorOptions> DOPivot(this RectTransform target, Vector2 endValue, float duration) { TweenerCore <Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.pivot, x => target.pivot = x, endValue, duration); t.SetTarget(target); return(t); }
/// <summary>Tweens a Outline's effectDistance to the given value. /// Also stores the Outline as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> public static TweenerCore <Vector2, Vector2, VectorOptions> DOScale(this Outline target, Vector2 endValue, float duration) { TweenerCore <Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.effectDistance, x => target.effectDistance = x, endValue, duration); t.SetTarget(target); return(t); }
/// <summary>Tweens a Material's named texture scale property with the given ID to the given value. /// Also stores the material as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param> /// <param name="propertyID">The ID of the material property to tween (also called nameID in Unity's manual)</param> /// <param name="duration">The duration of the tween</param> public static TweenerCore<Vector2, Vector2, VectorOptions> DOTiling(this Material target, Vector2 endValue, int propertyID, float duration) { if (!target.HasProperty(propertyID)) { if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID); return null; } TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.GetTextureScale(propertyID), x => target.SetTextureScale(propertyID, x), endValue, duration); t.SetTarget(target); return t; }
public static Tweener DORotate(this Transform target, Vector3 endValue, float duration, RotateMode mode = 0) { TweenerCore <Quaternion, Vector3, QuaternionOptions> t = DOTween.To(() => target.rotation, delegate(Quaternion x) { target.rotation = x; }, endValue, duration); t.SetTarget <TweenerCore <Quaternion, Vector3, QuaternionOptions> >(target); t.plugOptions.rotateMode = mode; return(t); }
public static Tweener DOLocalRotateQuaternion(this Transform target, Quaternion endValue, float duration) { TweenerCore <Quaternion, Quaternion, NoOptions> tweenerCore = DOTween.To(PureQuaternionPlugin.Plug(), () => target.localRotation, delegate(Quaternion x) { target.localRotation = x; }, endValue, duration); tweenerCore.SetTarget(target); return(tweenerCore); }
/// <summary>Tweens an AudioMixer's exposed float to the given value. /// Also stores the AudioMixer as the tween's target so it can be used for filtered operations. /// Note that you need to manually expose a float in an AudioMixerGroup in order to be able to tween it from an AudioMixer.</summary> /// <param name="floatName">Name given to the exposed float to set</param> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> public static TweenerCore <float, float, FloatOptions> DOSetFloat(this AudioMixer target, string floatName, float endValue, float duration) { TweenerCore <float, float, FloatOptions> t = DOTween.To(() => { float currVal; target.GetFloat(floatName, out currVal); return(currVal); }, x => target.SetFloat(floatName, x), endValue, duration); t.SetTarget(target); return(t); }
public static TweenerCore <int, int, NoOptions> DOFormatNumericToString( this Text target, int fromValue, int endValue, float duration, Func <int, string> toString) { int v = fromValue; TweenerCore <int, int, NoOptions> t = DOTween.To(() => v, x => { v = x; target.text = toString.Invoke(v); }, endValue, duration); t.SetTarget(target); return(t); }
/// <summary>Tweens an AudioSource's volume to the given value. /// Also stores the AudioSource as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach (0 to 1)</param><param name="duration">The duration of the tween</param> public static TweenerCore <float, float, FloatOptions> DOFade(this AudioSource target, float endValue, float duration) { if (endValue < 0) { endValue = 0; } else if (endValue > 1) { endValue = 1; } TweenerCore <float, float, FloatOptions> t = DOTween.To(() => target.volume, x => target.volume = x, endValue, duration); t.SetTarget(target); return(t); }
/// <summary>Tweens a Material's named texture offset property with the given ID to the given value. /// Also stores the material as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param> /// <param name="propertyID">The ID of the material property to tween (also called nameID in Unity's manual)</param> /// <param name="duration">The duration of the tween</param> public static TweenerCore <Vector2, Vector2, VectorOptions> DOOffset(this Material target, Vector2 endValue, int propertyID, float duration) { if (!target.HasProperty(propertyID)) { if (Debugger.logPriority > 0) { Debugger.LogMissingMaterialProperty(propertyID); } return(null); } TweenerCore <Vector2, Vector2, VectorOptions> t = DG.Tweening.DOTween.To(() => target.GetTextureOffset(propertyID), x => target.SetTextureOffset(propertyID, x), endValue, duration); t.SetTarget(target); return(t); }
/// <summary>Tweens an Image's fillAmount to the given value. /// Also stores the sprite as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach (0 to 1)</param><param name="duration">The duration of the tween</param> public static TweenerCore <float, float, FloatOptions> DOFillAmount(this Image target, float endValue, float duration) { if (endValue > 1) { endValue = 1; } else if (endValue < 0) { endValue = 0; } TweenerCore <float, float, FloatOptions> t = DOTween.To(() => target.fillAmount, x => target.fillAmount = x, endValue, duration); t.SetTarget(target); return(t); }
/// <summary> /// Tweens a Text's text from one integer to another, with options for thousands separators /// </summary> /// <param name="fromValue">The value to start from</param> /// <param name="endValue">The end value to reach</param> /// <param name="duration">The duration of the tween</param> /// <param name="addThousandsSeparator">If TRUE (default) also adds thousands separators</param> /// <param name="culture">The <see cref="CultureInfo"/> to use (InvariantCulture if NULL)</param> public static TweenerCore <int, int, NoOptions> DOCounter( this Text target, int fromValue, int endValue, float duration, bool addThousandsSeparator = true, CultureInfo culture = null ) { int v = fromValue; CultureInfo cInfo = !addThousandsSeparator ? null : culture ?? CultureInfo.InvariantCulture; TweenerCore <int, int, NoOptions> t = DOTween.To(() => v, x => { v = x; target.text = addThousandsSeparator ? v.ToString("N0", cInfo) : v.ToString(); }, endValue, duration); t.SetTarget(target); return(t); }
private void StartMoveToTarget(Vector3 target) { if (isStunned) { return; } if (startGameManager.inSetup) { return; } start = transform.position; this.target = new Vector3(target.x, transform.position.y, target.z); startDist = Vector3.Distance(start, this.target); SetMoving(true); transform.LookAt(this.target); //TODO with sequence to lerp up then steady then down if (moveTween != null && moveTween.IsPlaying()) { moveTween.SetTarget(this.target); moveTween.ChangeValues(start, this.target, startDist / speed); } else { moveTween = transform.DOMove(this.target, startDist / speed); moveTween.OnUpdate(() => { var t = (Mathf.Sin(moveTween.ElapsedPercentage().Remap(0, 1, -Mathf.PI + Mathf.PI / 2, Mathf.PI + Mathf.PI / 2)) + 1) / 2.0f; animator.SetFloat("Speed", t); if (!isMoving || isStunned) { moveTween.Kill(); } }); moveTween.OnComplete(() => { SetMoving(false); }); moveTween.OnKill(() => { SetMoving(false); }); } }