1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2026-02-11 17:48:47 +08:00

All chained settings now check for null tweens + Added HasProperty check to Material shortcuts that tween a specific property + Added Material.DOAlpha with specific-property parameter

This commit is contained in:
Daniele Giardini 2015-04-13 14:30:21 +02:00
parent c82c606db2
commit 42e1ef8180
32 changed files with 129 additions and 56 deletions

View File

@ -918,6 +918,14 @@
Also stores the material as the tween's target so it can be used for filtered operations</summary> 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="duration">The duration of the tween</param> <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
</member> </member>
<member name="M:DG.Tweening.ShortcutExtensions.DOFade(UnityEngine.Material,System.Single,System.String,System.Single)">
<summary>Tweens a Material's alpha color to the given value
(will have no effect unless your material supports transparency).
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="property">The name of the material property to tween (like _Tint or _SpecColor)</param>
<param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOFloat(UnityEngine.Material,System.Single,System.String,System.Single)"> <member name="M:DG.Tweening.ShortcutExtensions.DOFloat(UnityEngine.Material,System.Single,System.String,System.Single)">
<summary>Tweens a Material's named float property to the given value. <summary>Tweens a Material's named float property to the given value.
Also stores the material as the tween's target so it can be used for filtered operations</summary> Also stores the material as the tween's target so it can be used for filtered operations</summary>

View File

@ -918,6 +918,14 @@
Also stores the material as the tween's target so it can be used for filtered operations</summary> 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="duration">The duration of the tween</param> <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
</member> </member>
<member name="M:DG.Tweening.ShortcutExtensions.DOFade(UnityEngine.Material,System.Single,System.String,System.Single)">
<summary>Tweens a Material's alpha color to the given value
(will have no effect unless your material supports transparency).
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="property">The name of the material property to tween (like _Tint or _SpecColor)</param>
<param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOFloat(UnityEngine.Material,System.Single,System.String,System.Single)"> <member name="M:DG.Tweening.ShortcutExtensions.DOFloat(UnityEngine.Material,System.Single,System.String,System.Single)">
<summary>Tweens a Material's named float property to the given value. <summary>Tweens a Material's named float property to the given value.
Also stores the material as the tween's target so it can be used for filtered operations</summary> Also stores the material as the tween's target so it can be used for filtered operations</summary>

View File

@ -918,6 +918,14 @@
Also stores the material as the tween's target so it can be used for filtered operations</summary> 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="duration">The duration of the tween</param> <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
</member> </member>
<member name="M:DG.Tweening.ShortcutExtensions.DOFade(UnityEngine.Material,System.Single,System.String,System.Single)">
<summary>Tweens a Material's alpha color to the given value
(will have no effect unless your material supports transparency).
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="property">The name of the material property to tween (like _Tint or _SpecColor)</param>
<param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOFloat(UnityEngine.Material,System.Single,System.String,System.Single)"> <member name="M:DG.Tweening.ShortcutExtensions.DOFloat(UnityEngine.Material,System.Single,System.String,System.Single)">
<summary>Tweens a Material's named float property to the given value. <summary>Tweens a Material's named float property to the given value.
Also stores the material as the tween's target so it can be used for filtered operations</summary> Also stores the material as the tween's target so it can be used for filtered operations</summary>

View File

@ -60,6 +60,11 @@ namespace DG.Tweening.Core
LogWarning("This Tween is not a path tween"); LogWarning("This Tween is not a path tween");
} }
public static void LogMissingMaterialProperty(string propertyName)
{
LogWarning(string.Format("This material doesn't have a {0} property", propertyName));
}
public static void SetLogPriority(LogBehaviour logBehaviour) public static void SetLogPriority(LogBehaviour logBehaviour)
{ {
switch (logBehaviour) { switch (logBehaviour) {

View File

@ -21,7 +21,7 @@ namespace DG.Tweening
public class DOTween public class DOTween
{ {
/// <summary>DOTween's version</summary> /// <summary>DOTween's version</summary>
public static readonly string Version = "1.0.480"; public static readonly string Version = "1.0.490";
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Options //////////////////////////////////// // Options ////////////////////////////////////

View File

@ -166,6 +166,10 @@ namespace DG.Tweening
/// <param name="duration">The duration of the tween</param> /// <param name="duration">The duration of the tween</param>
public static Tweener DOColor(this Material target, Color endValue, string property, float duration) public static Tweener DOColor(this Material target, Color endValue, string property, float duration)
{ {
if (!target.HasProperty(property)) {
if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(property);
return null;
}
return DOTween.To(() => target.GetColor(property), x => target.SetColor(property, x), endValue, duration).SetTarget(target); return DOTween.To(() => target.GetColor(property), x => target.SetColor(property, x), endValue, duration).SetTarget(target);
} }
@ -178,6 +182,20 @@ namespace DG.Tweening
return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration) return DOTween.ToAlpha(() => target.color, x => target.color = x, endValue, duration)
.SetTarget(target); .SetTarget(target);
} }
/// <summary>Tweens a Material's alpha color to the given value
/// (will have no effect unless your material supports transparency).
/// 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="property">The name of the material property to tween (like _Tint or _SpecColor)</param>
/// <param name="duration">The duration of the tween</param>
public static Tweener DOFade(this Material target, float endValue, string property, float duration)
{
if (!target.HasProperty(property)) {
if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(property);
return null;
}
return DOTween.ToAlpha(() => target.GetColor(property), x => target.SetColor(property, x), endValue, duration).SetTarget(target);
}
/// <summary>Tweens a Material's named float property to the given value. /// <summary>Tweens a Material's named float property to the given value.
/// Also stores the material as the tween's target so it can be used for filtered operations</summary> /// Also stores the material as the tween's target so it can be used for filtered operations</summary>
@ -186,6 +204,10 @@ namespace DG.Tweening
/// <param name="duration">The duration of the tween</param> /// <param name="duration">The duration of the tween</param>
public static Tweener DOFloat(this Material target, float endValue, string property, float duration) public static Tweener DOFloat(this Material target, float endValue, string property, float duration)
{ {
if (!target.HasProperty(property)) {
if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(property);
return null;
}
return DOTween.To(() => target.GetFloat(property), x => target.SetFloat(property, x), endValue, duration).SetTarget(target); return DOTween.To(() => target.GetFloat(property), x => target.SetFloat(property, x), endValue, duration).SetTarget(target);
} }
@ -196,6 +218,10 @@ namespace DG.Tweening
/// <param name="duration">The duration of the tween</param> /// <param name="duration">The duration of the tween</param>
public static Tweener DOVector(this Material target, Vector4 endValue, string property, float duration) public static Tweener DOVector(this Material target, Vector4 endValue, string property, float duration)
{ {
if (!target.HasProperty(property)) {
if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(property);
return null;
}
return DOTween.To(() => target.GetVector(property), x => target.SetVector(property, x), endValue, duration).SetTarget(target); return DOTween.To(() => target.GetVector(property), x => target.SetVector(property, x), endValue, duration).SetTarget(target);
} }

View File

@ -25,7 +25,7 @@ namespace DG.Tweening
/// Has no effect if the tween has already started</summary> /// Has no effect if the tween has already started</summary>
public static T SetAutoKill<T>(this T t) where T : Tween public static T SetAutoKill<T>(this T t) where T : Tween
{ {
if (!t.active || t.creationLocked) return t; if (t == null || !t.active || t.creationLocked) return t;
t.autoKill = true; t.autoKill = true;
return t; return t;
@ -35,7 +35,7 @@ namespace DG.Tweening
/// <param name="autoKillOnCompletion">If TRUE the tween will be automatically killed when complete</param> /// <param name="autoKillOnCompletion">If TRUE the tween will be automatically killed when complete</param>
public static T SetAutoKill<T>(this T t, bool autoKillOnCompletion) where T : Tween public static T SetAutoKill<T>(this T t, bool autoKillOnCompletion) where T : Tween
{ {
if (!t.active || t.creationLocked) return t; if (t == null || !t.active || t.creationLocked) return t;
t.autoKill = autoKillOnCompletion; t.autoKill = autoKillOnCompletion;
return t; return t;
@ -45,7 +45,7 @@ namespace DG.Tweening
/// <param name="id">The ID to assign to this tween. Can be an int, a string, an object or anything else.</param> /// <param name="id">The ID to assign to this tween. Can be an int, a string, an object or anything else.</param>
public static T SetId<T>(this T t, object id) where T : Tween public static T SetId<T>(this T t, object id) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.id = id; t.id = id;
return t; return t;
@ -58,7 +58,7 @@ namespace DG.Tweening
/// <param name="target">The target to assign to this tween. Can be an int, a string, an object or anything else.</param> /// <param name="target">The target to assign to this tween. Can be an int, a string, an object or anything else.</param>
public static T SetTarget<T>(this T t, object target) where T : Tween public static T SetTarget<T>(this T t, object target) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.target = target; t.target = target;
return t; return t;
@ -69,7 +69,7 @@ namespace DG.Tweening
/// <param name="loops">Number of cycles to play (-1 for infinite - will be converted to 1 in case the tween is nested in a Sequence)</param> /// <param name="loops">Number of cycles to play (-1 for infinite - will be converted to 1 in case the tween is nested in a Sequence)</param>
public static T SetLoops<T>(this T t, int loops) where T : Tween public static T SetLoops<T>(this T t, int loops) where T : Tween
{ {
if (!t.active || t.creationLocked) return t; if (t == null || !t.active || t.creationLocked) return t;
if (loops < -1) loops = -1; if (loops < -1) loops = -1;
else if (loops == 0) loops = 1; else if (loops == 0) loops = 1;
@ -87,7 +87,7 @@ namespace DG.Tweening
/// <param name="loopType">Loop behaviour type (default: LoopType.Restart)</param> /// <param name="loopType">Loop behaviour type (default: LoopType.Restart)</param>
public static T SetLoops<T>(this T t, int loops, LoopType loopType) where T : Tween public static T SetLoops<T>(this T t, int loops, LoopType loopType) where T : Tween
{ {
if (!t.active || t.creationLocked) return t; if (t == null || !t.active || t.creationLocked) return t;
if (loops < -1) loops = -1; if (loops < -1) loops = -1;
else if (loops == 0) loops = 1; else if (loops == 0) loops = 1;
@ -105,7 +105,7 @@ namespace DG.Tweening
/// <para>If applied to Sequences eases the whole sequence animation</para></summary> /// <para>If applied to Sequences eases the whole sequence animation</para></summary>
public static T SetEase<T>(this T t, Ease ease) where T : Tween public static T SetEase<T>(this T t, Ease ease) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.easeType = ease; t.easeType = ease;
t.customEase = null; t.customEase = null;
@ -116,7 +116,7 @@ namespace DG.Tweening
/// <param name="overshoot">Eventual overshoot to use with Back ease (default is 1.70158)</param> /// <param name="overshoot">Eventual overshoot to use with Back ease (default is 1.70158)</param>
public static T SetEase<T>(this T t, Ease ease, float overshoot) where T : Tween public static T SetEase<T>(this T t, Ease ease, float overshoot) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.easeType = ease; t.easeType = ease;
t.easeOvershootOrAmplitude = overshoot; t.easeOvershootOrAmplitude = overshoot;
@ -129,7 +129,7 @@ namespace DG.Tweening
/// <param name="period">Eventual period to use with Elastic easeType (default is 0)</param> /// <param name="period">Eventual period to use with Elastic easeType (default is 0)</param>
public static T SetEase<T>(this T t, Ease ease, float amplitude, float period) where T : Tween public static T SetEase<T>(this T t, Ease ease, float amplitude, float period) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.easeType = ease; t.easeType = ease;
t.easeOvershootOrAmplitude = amplitude; t.easeOvershootOrAmplitude = amplitude;
@ -141,7 +141,7 @@ namespace DG.Tweening
/// <para>If applied to Sequences eases the whole sequence animation</para></summary> /// <para>If applied to Sequences eases the whole sequence animation</para></summary>
public static T SetEase<T>(this T t, AnimationCurve animCurve) where T : Tween public static T SetEase<T>(this T t, AnimationCurve animCurve) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.easeType = Ease.INTERNAL_Custom; t.easeType = Ease.INTERNAL_Custom;
t.customEase = new EaseCurve(animCurve).Evaluate; t.customEase = new EaseCurve(animCurve).Evaluate;
@ -151,7 +151,7 @@ namespace DG.Tweening
/// <para>If applied to Sequences eases the whole sequence animation</para></summary> /// <para>If applied to Sequences eases the whole sequence animation</para></summary>
public static T SetEase<T>(this T t, EaseFunction customEase) where T : Tween public static T SetEase<T>(this T t, EaseFunction customEase) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.easeType = Ease.INTERNAL_Custom; t.easeType = Ease.INTERNAL_Custom;
t.customEase = customEase; t.customEase = customEase;
@ -161,7 +161,7 @@ namespace DG.Tweening
/// <summary>Allows the tween to be recycled after being killed.</summary> /// <summary>Allows the tween to be recycled after being killed.</summary>
public static T SetRecyclable<T>(this T t) where T : Tween public static T SetRecyclable<T>(this T t) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.isRecyclable = true; t.isRecyclable = true;
return t; return t;
@ -170,7 +170,7 @@ namespace DG.Tweening
/// <param name="recyclable">If TRUE the tween will be recycled after being killed, otherwise it will be destroyed.</param> /// <param name="recyclable">If TRUE the tween will be recycled after being killed, otherwise it will be destroyed.</param>
public static T SetRecyclable<T>(this T t, bool recyclable) where T : Tween public static T SetRecyclable<T>(this T t, bool recyclable) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.isRecyclable = recyclable; t.isRecyclable = recyclable;
return t; return t;
@ -180,7 +180,7 @@ namespace DG.Tweening
/// <param name="isIndependentUpdate">If TRUE the tween will ignore Unity's Time.timeScale</param> /// <param name="isIndependentUpdate">If TRUE the tween will ignore Unity's Time.timeScale</param>
public static T SetUpdate<T>(this T t, bool isIndependentUpdate) where T : Tween public static T SetUpdate<T>(this T t, bool isIndependentUpdate) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
TweenManager.SetUpdateType(t, DOTween.defaultUpdateType, isIndependentUpdate); TweenManager.SetUpdateType(t, DOTween.defaultUpdateType, isIndependentUpdate);
return t; return t;
@ -190,7 +190,7 @@ namespace DG.Tweening
/// <param name="isIndependentUpdate">If TRUE the tween will ignore Unity's Time.timeScale</param> /// <param name="isIndependentUpdate">If TRUE the tween will ignore Unity's Time.timeScale</param>
public static T SetUpdate<T>(this T t, UpdateType updateType, bool isIndependentUpdate = false) where T : Tween public static T SetUpdate<T>(this T t, UpdateType updateType, bool isIndependentUpdate = false) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
TweenManager.SetUpdateType(t, updateType, isIndependentUpdate); TweenManager.SetUpdateType(t, updateType, isIndependentUpdate);
return t; return t;
@ -200,7 +200,7 @@ namespace DG.Tweening
/// Called the first time the tween is set in a playing state, after any eventual delay</summary> /// Called the first time the tween is set in a playing state, after any eventual delay</summary>
public static T OnStart<T>(this T t, TweenCallback action) where T : Tween public static T OnStart<T>(this T t, TweenCallback action) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.onStart = action; t.onStart = action;
return t; return t;
@ -211,7 +211,7 @@ namespace DG.Tweening
/// Also called each time the tween resumes playing from a paused state</summary> /// Also called each time the tween resumes playing from a paused state</summary>
public static T OnPlay<T>(this T t, TweenCallback action) where T : Tween public static T OnPlay<T>(this T t, TweenCallback action) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.onPlay = action; t.onPlay = action;
return t; return t;
@ -222,7 +222,7 @@ namespace DG.Tweening
/// If the tween has autoKill set to FALSE, this is called also when the tween reaches completion.</summary> /// If the tween has autoKill set to FALSE, this is called also when the tween reaches completion.</summary>
public static T OnPause<T>(this T t, TweenCallback action) where T : Tween public static T OnPause<T>(this T t, TweenCallback action) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.onPause = action; t.onPause = action;
return t; return t;
@ -234,7 +234,7 @@ namespace DG.Tweening
/// Rewinding a tween that is already rewinded will not fire this callback</summary> /// Rewinding a tween that is already rewinded will not fire this callback</summary>
public static T OnRewind<T>(this T t, TweenCallback action) where T : Tween public static T OnRewind<T>(this T t, TweenCallback action) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.onRewind = action; t.onRewind = action;
return t; return t;
@ -244,7 +244,7 @@ namespace DG.Tweening
/// Called each time the tween updates</summary> /// Called each time the tween updates</summary>
public static T OnUpdate<T>(this T t, TweenCallback action) where T : Tween public static T OnUpdate<T>(this T t, TweenCallback action) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.onUpdate = action; t.onUpdate = action;
return t; return t;
@ -254,7 +254,7 @@ namespace DG.Tweening
/// Called the moment the tween completes one loop cycle, even when going backwards</summary> /// Called the moment the tween completes one loop cycle, even when going backwards</summary>
public static T OnStepComplete<T>(this T t, TweenCallback action) where T : Tween public static T OnStepComplete<T>(this T t, TweenCallback action) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.onStepComplete = action; t.onStepComplete = action;
return t; return t;
@ -264,7 +264,7 @@ namespace DG.Tweening
/// Called the moment the tween reaches its final forward position, loops included</summary> /// Called the moment the tween reaches its final forward position, loops included</summary>
public static T OnComplete<T>(this T t, TweenCallback action) where T : Tween public static T OnComplete<T>(this T t, TweenCallback action) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.onComplete = action; t.onComplete = action;
return t; return t;
@ -274,7 +274,7 @@ namespace DG.Tweening
/// Called the moment the tween is killed</summary> /// Called the moment the tween is killed</summary>
public static T OnKill<T>(this T t, TweenCallback action) where T : Tween public static T OnKill<T>(this T t, TweenCallback action) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.onKill = action; t.onKill = action;
return t; return t;
@ -284,7 +284,7 @@ namespace DG.Tweening
/// Called when a path tween's current waypoint changes</summary> /// Called when a path tween's current waypoint changes</summary>
public static T OnWaypointChange<T>(this T t, TweenCallback<int> action) where T : Tween public static T OnWaypointChange<T>(this T t, TweenCallback<int> action) where T : Tween
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.onWaypointChange = action; t.onWaypointChange = action;
return t; return t;
@ -297,7 +297,7 @@ namespace DG.Tweening
/// <param name="asTween">Tween from which to copy the parameters</param> /// <param name="asTween">Tween from which to copy the parameters</param>
public static T SetAs<T>(this T t, Tween asTween) where T : Tween public static T SetAs<T>(this T t, Tween asTween) where T : Tween
{ {
if (!t.active || t.creationLocked) return t; if (t == null || !t.active || t.creationLocked) return t;
// t.isFrom = asTween.isFrom; // t.isFrom = asTween.isFrom;
// t.target = asTween.target; // t.target = asTween.target;
@ -341,7 +341,7 @@ namespace DG.Tweening
/// <param name="tweenParams">TweenParams from which to copy the parameters</param> /// <param name="tweenParams">TweenParams from which to copy the parameters</param>
public static T SetAs<T>(this T t, TweenParams tweenParams) where T : Tween public static T SetAs<T>(this T t, TweenParams tweenParams) where T : Tween
{ {
if (!t.active || t.creationLocked) return t; if (t == null || !t.active || t.creationLocked) return t;
TweenManager.SetUpdateType(t, tweenParams.updateType, tweenParams.isIndependentUpdate); TweenManager.SetUpdateType(t, tweenParams.updateType, tweenParams.isIndependentUpdate);
t.id = tweenParams.id; t.id = tweenParams.id;
@ -388,7 +388,7 @@ namespace DG.Tweening
/// <param name="t">The tween to append</param> /// <param name="t">The tween to append</param>
public static Sequence Append(this Sequence s, Tween t) public static Sequence Append(this Sequence s, Tween t)
{ {
if (!s.active || s.creationLocked) return s; if (s == null || !s.active || s.creationLocked) return s;
if (t == null || !t.active) return s; if (t == null || !t.active) return s;
Sequence.DoInsert(s, t, s.duration); Sequence.DoInsert(s, t, s.duration);
@ -399,7 +399,7 @@ namespace DG.Tweening
/// <param name="t">The tween to prepend</param> /// <param name="t">The tween to prepend</param>
public static Sequence Prepend(this Sequence s, Tween t) public static Sequence Prepend(this Sequence s, Tween t)
{ {
if (!s.active || s.creationLocked) return s; if (s == null || !s.active || s.creationLocked) return s;
if (t == null || !t.active) return s; if (t == null || !t.active) return s;
Sequence.DoPrepend(s, t); Sequence.DoPrepend(s, t);
@ -409,7 +409,7 @@ namespace DG.Tweening
/// Has no effect if the Sequence has already started</summary> /// Has no effect if the Sequence has already started</summary>
public static Sequence Join(this Sequence s, Tween t) public static Sequence Join(this Sequence s, Tween t)
{ {
if (!s.active || s.creationLocked) return s; if (s == null || !s.active || s.creationLocked) return s;
if (t == null || !t.active) return s; if (t == null || !t.active) return s;
Sequence.DoInsert(s, t, s.lastTweenInsertTime); Sequence.DoInsert(s, t, s.lastTweenInsertTime);
@ -422,7 +422,7 @@ namespace DG.Tweening
/// <param name="t">The tween to insert</param> /// <param name="t">The tween to insert</param>
public static Sequence Insert(this Sequence s, float atPosition, Tween t) public static Sequence Insert(this Sequence s, float atPosition, Tween t)
{ {
if (!s.active || s.creationLocked) return s; if (s == null || !s.active || s.creationLocked) return s;
if (t == null || !t.active) return s; if (t == null || !t.active) return s;
Sequence.DoInsert(s, t, atPosition); Sequence.DoInsert(s, t, atPosition);
@ -434,7 +434,7 @@ namespace DG.Tweening
/// <param name="interval">The interval duration</param> /// <param name="interval">The interval duration</param>
public static Sequence AppendInterval(this Sequence s, float interval) public static Sequence AppendInterval(this Sequence s, float interval)
{ {
if (!s.active || s.creationLocked) return s; if (s == null || !s.active || s.creationLocked) return s;
Sequence.DoAppendInterval(s, interval); Sequence.DoAppendInterval(s, interval);
return s; return s;
@ -444,7 +444,7 @@ namespace DG.Tweening
/// <param name="interval">The interval duration</param> /// <param name="interval">The interval duration</param>
public static Sequence PrependInterval(this Sequence s, float interval) public static Sequence PrependInterval(this Sequence s, float interval)
{ {
if (!s.active || s.creationLocked) return s; if (s == null || !s.active || s.creationLocked) return s;
Sequence.DoPrependInterval(s, interval); Sequence.DoPrependInterval(s, interval);
return s; return s;
@ -455,7 +455,7 @@ namespace DG.Tweening
/// <param name="callback">The callback to append</param> /// <param name="callback">The callback to append</param>
public static Sequence AppendCallback(this Sequence s, TweenCallback callback) public static Sequence AppendCallback(this Sequence s, TweenCallback callback)
{ {
if (!s.active || s.creationLocked) return s; if (s == null || !s.active || s.creationLocked) return s;
if (callback == null) return s; if (callback == null) return s;
Sequence.DoInsertCallback(s, callback, s.duration); Sequence.DoInsertCallback(s, callback, s.duration);
@ -466,7 +466,7 @@ namespace DG.Tweening
/// <param name="callback">The callback to prepend</param> /// <param name="callback">The callback to prepend</param>
public static Sequence PrependCallback(this Sequence s, TweenCallback callback) public static Sequence PrependCallback(this Sequence s, TweenCallback callback)
{ {
if (!s.active || s.creationLocked) return s; if (s == null || !s.active || s.creationLocked) return s;
if (callback == null) return s; if (callback == null) return s;
Sequence.DoInsertCallback(s, callback, 0); Sequence.DoInsertCallback(s, callback, 0);
@ -479,7 +479,7 @@ namespace DG.Tweening
/// <param name="callback">The callback to insert</param> /// <param name="callback">The callback to insert</param>
public static Sequence InsertCallback(this Sequence s, float atPosition, TweenCallback callback) public static Sequence InsertCallback(this Sequence s, float atPosition, TweenCallback callback)
{ {
if (!s.active || s.creationLocked) return s; if (s == null || !s.active || s.creationLocked) return s;
if (callback == null) return s; if (callback == null) return s;
Sequence.DoInsertCallback(s, callback, atPosition); Sequence.DoInsertCallback(s, callback, atPosition);
@ -493,7 +493,7 @@ namespace DG.Tweening
/// then immediately sends the target to the previously set endValue.</summary> /// then immediately sends the target to the previously set endValue.</summary>
public static T From<T>(this T t) where T : Tweener public static T From<T>(this T t) where T : Tweener
{ {
if (!t.active || t.creationLocked || !t.isFromAllowed) return t; if (t == null || !t.active || t.creationLocked || !t.isFromAllowed) return t;
t.isFrom = true; t.isFrom = true;
t.SetFrom(false); t.SetFrom(false);
@ -504,7 +504,7 @@ namespace DG.Tweening
/// <param name="isRelative">If TRUE the FROM value will be calculated as relative to the current one</param> /// <param name="isRelative">If TRUE the FROM value will be calculated as relative to the current one</param>
public static T From<T>(this T t, bool isRelative) where T : Tweener public static T From<T>(this T t, bool isRelative) where T : Tweener
{ {
if (!t.active || t.creationLocked || !t.isFromAllowed) return t; if (t == null || !t.active || t.creationLocked || !t.isFromAllowed) return t;
t.isFrom = true; t.isFrom = true;
if (!isRelative) t.SetFrom(false); if (!isRelative) t.SetFrom(false);
@ -516,7 +516,7 @@ namespace DG.Tweening
/// <para>Has no effect on Sequences or if the tween has already started</para></summary> /// <para>Has no effect on Sequences or if the tween has already started</para></summary>
public static T SetDelay<T>(this T t, float delay) where T : Tween public static T SetDelay<T>(this T t, float delay) where T : Tween
{ {
if (!t.active || t.creationLocked) return t; if (t == null || !t.active || t.creationLocked) return t;
t.delay = delay; t.delay = delay;
t.delayComplete = delay <= 0; t.delayComplete = delay <= 0;
@ -528,7 +528,7 @@ namespace DG.Tweening
/// <para>Has no effect on Sequences or if the tween has already started</para></summary> /// <para>Has no effect on Sequences or if the tween has already started</para></summary>
public static T SetRelative<T>(this T t) where T : Tween public static T SetRelative<T>(this T t) where T : Tween
{ {
if (!t.active || t.creationLocked || t.isFrom || t.isBlendable) return t; if (t == null || !t.active || t.creationLocked || t.isFrom || t.isBlendable) return t;
t.isRelative = true; t.isRelative = true;
return t; return t;
@ -538,7 +538,7 @@ namespace DG.Tweening
/// <para>Has no effect on Sequences or if the tween has already started</para></summary> /// <para>Has no effect on Sequences or if the tween has already started</para></summary>
public static T SetRelative<T>(this T t, bool isRelative) where T : Tween public static T SetRelative<T>(this T t, bool isRelative) where T : Tween
{ {
if (!t.active || t.creationLocked || t.isFrom || t.isBlendable) return t; if (t == null || !t.active || t.creationLocked || t.isFrom || t.isBlendable) return t;
t.isRelative = isRelative; t.isRelative = isRelative;
return t; return t;
@ -549,7 +549,7 @@ namespace DG.Tweening
/// <para>Has no effect on Sequences, nested tweens, or if the tween has already started</para></summary> /// <para>Has no effect on Sequences, nested tweens, or if the tween has already started</para></summary>
public static T SetSpeedBased<T>(this T t) where T : Tween public static T SetSpeedBased<T>(this T t) where T : Tween
{ {
if (!t.active || t.creationLocked) return t; if (t == null || !t.active || t.creationLocked) return t;
t.isSpeedBased = true; t.isSpeedBased = true;
return t; return t;
@ -559,7 +559,7 @@ namespace DG.Tweening
/// <para>Has no effect on Sequences, nested tweens, or if the tween has already started</para></summary> /// <para>Has no effect on Sequences, nested tweens, or if the tween has already started</para></summary>
public static T SetSpeedBased<T>(this T t, bool isSpeedBased) where T : Tween public static T SetSpeedBased<T>(this T t, bool isSpeedBased) where T : Tween
{ {
if (!t.active || t.creationLocked) return t; if (t == null || !t.active || t.creationLocked) return t;
t.isSpeedBased = isSpeedBased; t.isSpeedBased = isSpeedBased;
return t; return t;
@ -573,7 +573,7 @@ namespace DG.Tweening
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener SetOptions(this TweenerCore<float, float, FloatOptions> t, bool snapping) public static Tweener SetOptions(this TweenerCore<float, float, FloatOptions> t, bool snapping)
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.plugOptions.snapping = snapping; t.plugOptions.snapping = snapping;
return t; return t;
@ -583,7 +583,7 @@ namespace DG.Tweening
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener SetOptions(this TweenerCore<Vector2, Vector2, VectorOptions> t, bool snapping) public static Tweener SetOptions(this TweenerCore<Vector2, Vector2, VectorOptions> t, bool snapping)
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.plugOptions.snapping = snapping; t.plugOptions.snapping = snapping;
return t; return t;
@ -593,7 +593,7 @@ namespace DG.Tweening
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener SetOptions(this TweenerCore<Vector2, Vector2, VectorOptions> t, AxisConstraint axisConstraint, bool snapping = false) public static Tweener SetOptions(this TweenerCore<Vector2, Vector2, VectorOptions> t, AxisConstraint axisConstraint, bool snapping = false)
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.plugOptions.axisConstraint = axisConstraint; t.plugOptions.axisConstraint = axisConstraint;
t.plugOptions.snapping = snapping; t.plugOptions.snapping = snapping;
@ -604,7 +604,7 @@ namespace DG.Tweening
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener SetOptions(this TweenerCore<Vector3, Vector3, VectorOptions> t, bool snapping) public static Tweener SetOptions(this TweenerCore<Vector3, Vector3, VectorOptions> t, bool snapping)
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.plugOptions.snapping = snapping; t.plugOptions.snapping = snapping;
return t; return t;
@ -614,7 +614,7 @@ namespace DG.Tweening
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener SetOptions(this TweenerCore<Vector3, Vector3, VectorOptions> t, AxisConstraint axisConstraint, bool snapping = false) public static Tweener SetOptions(this TweenerCore<Vector3, Vector3, VectorOptions> t, AxisConstraint axisConstraint, bool snapping = false)
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.plugOptions.axisConstraint = axisConstraint; t.plugOptions.axisConstraint = axisConstraint;
t.plugOptions.snapping = snapping; t.plugOptions.snapping = snapping;
@ -625,7 +625,7 @@ namespace DG.Tweening
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener SetOptions(this TweenerCore<Vector4, Vector4, VectorOptions> t, bool snapping) public static Tweener SetOptions(this TweenerCore<Vector4, Vector4, VectorOptions> t, bool snapping)
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.plugOptions.snapping = snapping; t.plugOptions.snapping = snapping;
return t; return t;
@ -635,7 +635,7 @@ namespace DG.Tweening
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener SetOptions(this TweenerCore<Vector4, Vector4, VectorOptions> t, AxisConstraint axisConstraint, bool snapping = false) public static Tweener SetOptions(this TweenerCore<Vector4, Vector4, VectorOptions> t, AxisConstraint axisConstraint, bool snapping = false)
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.plugOptions.axisConstraint = axisConstraint; t.plugOptions.axisConstraint = axisConstraint;
t.plugOptions.snapping = snapping; t.plugOptions.snapping = snapping;
@ -647,7 +647,7 @@ namespace DG.Tweening
/// If FALSE the rotation will be fully accounted. Is always FALSE if the tween is set as relative</param> /// If FALSE the rotation will be fully accounted. Is always FALSE if the tween is set as relative</param>
public static Tweener SetOptions(this TweenerCore<Quaternion, Vector3, QuaternionOptions> t, bool useShortest360Route = true) public static Tweener SetOptions(this TweenerCore<Quaternion, Vector3, QuaternionOptions> t, bool useShortest360Route = true)
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.plugOptions.rotateMode = useShortest360Route ? RotateMode.Fast : RotateMode.FastBeyond360; t.plugOptions.rotateMode = useShortest360Route ? RotateMode.Fast : RotateMode.FastBeyond360;
return t; return t;
@ -657,7 +657,7 @@ namespace DG.Tweening
/// <param name="alphaOnly">If TRUE only the alpha value of the color will be tweened</param> /// <param name="alphaOnly">If TRUE only the alpha value of the color will be tweened</param>
public static Tweener SetOptions(this TweenerCore<Color, Color, ColorOptions> t, bool alphaOnly) public static Tweener SetOptions(this TweenerCore<Color, Color, ColorOptions> t, bool alphaOnly)
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.plugOptions.alphaOnly = alphaOnly; t.plugOptions.alphaOnly = alphaOnly;
return t; return t;
@ -667,7 +667,7 @@ namespace DG.Tweening
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener SetOptions(this TweenerCore<Rect, Rect, RectOptions> t, bool snapping) public static Tweener SetOptions(this TweenerCore<Rect, Rect, RectOptions> t, bool snapping)
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.plugOptions.snapping = snapping; t.plugOptions.snapping = snapping;
return t; return t;
@ -682,7 +682,7 @@ namespace DG.Tweening
/// Leave it to NULL to use default ones</param> /// Leave it to NULL to use default ones</param>
public static Tweener SetOptions(this TweenerCore<string, string, StringOptions> t, bool richTextEnabled, ScrambleMode scrambleMode = ScrambleMode.None, string scrambleChars = null) public static Tweener SetOptions(this TweenerCore<string, string, StringOptions> t, bool richTextEnabled, ScrambleMode scrambleMode = ScrambleMode.None, string scrambleChars = null)
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.plugOptions.richTextEnabled = richTextEnabled; t.plugOptions.richTextEnabled = richTextEnabled;
t.plugOptions.scrambleMode = scrambleMode; t.plugOptions.scrambleMode = scrambleMode;
@ -698,7 +698,7 @@ namespace DG.Tweening
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener SetOptions(this TweenerCore<Vector3, Vector3[], Vector3ArrayOptions> t, bool snapping) public static Tweener SetOptions(this TweenerCore<Vector3, Vector3[], Vector3ArrayOptions> t, bool snapping)
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.plugOptions.snapping = snapping; t.plugOptions.snapping = snapping;
return t; return t;
@ -707,7 +707,7 @@ namespace DG.Tweening
/// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
public static Tweener SetOptions(this TweenerCore<Vector3, Vector3[], Vector3ArrayOptions> t, AxisConstraint axisConstraint, bool snapping = false) public static Tweener SetOptions(this TweenerCore<Vector3, Vector3[], Vector3ArrayOptions> t, AxisConstraint axisConstraint, bool snapping = false)
{ {
if (!t.active) return t; if (t == null || !t.active) return t;
t.plugOptions.axisConstraint = axisConstraint; t.plugOptions.axisConstraint = axisConstraint;
t.plugOptions.snapping = snapping; t.plugOptions.snapping = snapping;
@ -739,6 +739,8 @@ namespace DG.Tweening
bool closePath, AxisConstraint lockPosition = AxisConstraint.None, AxisConstraint lockRotation = AxisConstraint.None bool closePath, AxisConstraint lockPosition = AxisConstraint.None, AxisConstraint lockRotation = AxisConstraint.None
) )
{ {
if (t == null || !t.active) return t;
t.plugOptions.isClosedPath = closePath; t.plugOptions.isClosedPath = closePath;
t.plugOptions.lockPositionAxis = lockPosition; t.plugOptions.lockPositionAxis = lockPosition;
t.plugOptions.lockRotationAxis = lockRotation; t.plugOptions.lockRotationAxis = lockRotation;
@ -756,6 +758,8 @@ namespace DG.Tweening
this TweenerCore<Vector3, Path, PathOptions> t, Vector3 lookAtPosition, Vector3? forwardDirection = null, Vector3? up = null this TweenerCore<Vector3, Path, PathOptions> t, Vector3 lookAtPosition, Vector3? forwardDirection = null, Vector3? up = null
) )
{ {
if (t == null || !t.active) return t;
t.plugOptions.orientType = OrientType.LookAtPosition; t.plugOptions.orientType = OrientType.LookAtPosition;
t.plugOptions.lookAtPosition = lookAtPosition; t.plugOptions.lookAtPosition = lookAtPosition;
SetPathForwardDirection(t, forwardDirection, up); SetPathForwardDirection(t, forwardDirection, up);
@ -772,6 +776,8 @@ namespace DG.Tweening
this TweenerCore<Vector3, Path, PathOptions> t, Transform lookAtTransform, Vector3? forwardDirection = null, Vector3? up = null this TweenerCore<Vector3, Path, PathOptions> t, Transform lookAtTransform, Vector3? forwardDirection = null, Vector3? up = null
) )
{ {
if (t == null || !t.active) return t;
t.plugOptions.orientType = OrientType.LookAtTransform; t.plugOptions.orientType = OrientType.LookAtTransform;
t.plugOptions.lookAtTransform = lookAtTransform; t.plugOptions.lookAtTransform = lookAtTransform;
SetPathForwardDirection(t, forwardDirection, up); SetPathForwardDirection(t, forwardDirection, up);
@ -788,6 +794,8 @@ namespace DG.Tweening
this TweenerCore<Vector3, Path, PathOptions> t, float lookAhead, Vector3? forwardDirection = null, Vector3? up = null this TweenerCore<Vector3, Path, PathOptions> t, float lookAhead, Vector3? forwardDirection = null, Vector3? up = null
) )
{ {
if (t == null || !t.active) return t;
t.plugOptions.orientType = OrientType.ToPath; t.plugOptions.orientType = OrientType.ToPath;
if (lookAhead < PathPlugin.MinLookAhead) lookAhead = PathPlugin.MinLookAhead; if (lookAhead < PathPlugin.MinLookAhead) lookAhead = PathPlugin.MinLookAhead;
t.plugOptions.lookAhead = lookAhead; t.plugOptions.lookAhead = lookAhead;
@ -797,6 +805,8 @@ namespace DG.Tweening
static void SetPathForwardDirection(this TweenerCore<Vector3, Path, PathOptions> t, Vector3? forwardDirection = null, Vector3? up = null) static void SetPathForwardDirection(this TweenerCore<Vector3, Path, PathOptions> t, Vector3? forwardDirection = null, Vector3? up = null)
{ {
if (t == null || !t.active) return;
t.plugOptions.hasCustomForwardDirection = forwardDirection != null && forwardDirection != Vector3.zero || up != null && up != Vector3.zero; t.plugOptions.hasCustomForwardDirection = forwardDirection != null && forwardDirection != Vector3.zero || up != null && up != Vector3.zero;
if (t.plugOptions.hasCustomForwardDirection) { if (t.plugOptions.hasCustomForwardDirection) {
if (forwardDirection == Vector3.zero) forwardDirection = Vector3.forward; if (forwardDirection == Vector3.zero) forwardDirection = Vector3.forward;

View File

@ -918,6 +918,14 @@
Also stores the material as the tween's target so it can be used for filtered operations</summary> 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="duration">The duration of the tween</param> <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
</member> </member>
<member name="M:DG.Tweening.ShortcutExtensions.DOFade(UnityEngine.Material,System.Single,System.String,System.Single)">
<summary>Tweens a Material's alpha color to the given value
(will have no effect unless your material supports transparency).
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="property">The name of the material property to tween (like _Tint or _SpecColor)</param>
<param name="duration">The duration of the tween</param>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOFloat(UnityEngine.Material,System.Single,System.String,System.Single)"> <member name="M:DG.Tweening.ShortcutExtensions.DOFloat(UnityEngine.Material,System.Single,System.String,System.Single)">
<summary>Tweens a Material's named float property to the given value. <summary>Tweens a Material's named float property to the given value.
Also stores the material as the tween's target so it can be used for filtered operations</summary> Also stores the material as the tween's target so it can be used for filtered operations</summary>

Binary file not shown.

Binary file not shown.

Binary file not shown.