1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 09:16:02 +08:00

Implemented Material shortcuts overloads (by Vasyl Romanets) that allow a propertyID/nameID parameter

This commit is contained in:
Demigiant 2019-02-09 12:08:55 +01:00
parent e86ff6a0c6
commit bdd94e8320
20 changed files with 248 additions and 4 deletions

View File

@ -1382,6 +1382,13 @@
<param name="property">The name of the material property to tween (like _Tint or _SpecColor)</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> <param name="duration">The duration of the tween</param>
</member> </member>
<member name="M:DG.Tweening.ShortcutExtensions.DOColor(UnityEngine.Material,UnityEngine.Color,System.Int32,System.Single)">
<summary>Tweens a Material's named color 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>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOFade(UnityEngine.Material,System.Single,System.Single)"> <member name="M:DG.Tweening.ShortcutExtensions.DOFade(UnityEngine.Material,System.Single,System.Single)">
<summary>Tweens a Material's alpha color to the given value <summary>Tweens a Material's alpha color to the given value
(will have no effect unless your material supports transparency). (will have no effect unless your material supports transparency).
@ -1396,6 +1403,14 @@
<param name="property">The name of the material property to tween (like _Tint or _SpecColor)</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> <param name="duration">The duration of the tween</param>
</member> </member>
<member name="M:DG.Tweening.ShortcutExtensions.DOFade(UnityEngine.Material,System.Single,System.Int32,System.Single)">
<summary>Tweens a Material's alpha color with the given ID 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="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>
</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>
@ -1403,6 +1418,13 @@
<param name="property">The name of the material property to tween</param> <param name="property">The name of the material property to tween</param>
<param name="duration">The duration of the tween</param> <param name="duration">The duration of the tween</param>
</member> </member>
<member name="M:DG.Tweening.ShortcutExtensions.DOFloat(UnityEngine.Material,System.Single,System.Int32,System.Single)">
<summary>Tweens a Material's named float 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>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOOffset(UnityEngine.Material,UnityEngine.Vector2,System.Single)"> <member name="M:DG.Tweening.ShortcutExtensions.DOOffset(UnityEngine.Material,UnityEngine.Vector2,System.Single)">
<summary>Tweens a Material's texture offset to the given value. <summary>Tweens a Material's texture offset 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>
@ -1436,6 +1458,13 @@
<param name="property">The name of the material property to tween</param> <param name="property">The name of the material property to tween</param>
<param name="duration">The duration of the tween</param> <param name="duration">The duration of the tween</param>
</member> </member>
<member name="M:DG.Tweening.ShortcutExtensions.DOVector(UnityEngine.Material,UnityEngine.Vector4,System.Int32,System.Single)">
<summary>Tweens a Material's named Vector 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>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOResize(UnityEngine.TrailRenderer,System.Single,System.Single,System.Single)"> <member name="M:DG.Tweening.ShortcutExtensions.DOResize(UnityEngine.TrailRenderer,System.Single,System.Single,System.Single)">
<summary>Tweens a TrailRenderer's startWidth/endWidth to the given value. <summary>Tweens a TrailRenderer's startWidth/endWidth to the given value.
Also stores the TrailRenderer as the tween's target so it can be used for filtered operations</summary> Also stores the TrailRenderer as the tween's target so it can be used for filtered operations</summary>
@ -1730,6 +1759,15 @@
<param name="property">The name of the material property to tween (like _Tint or _SpecColor)</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> <param name="duration">The duration of the tween</param>
</member> </member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableColor(UnityEngine.Material,UnityEngine.Color,System.Int32,System.Single)">
<summary>Tweens a Material's named color property with the given ID to the given value,
in a way that allows other DOBlendableColor tweens to work together on the same target,
instead than fight each other as multiple DOColor would do.
Also stores the Material as the tween's target so it can be used for filtered operations</summary>
<param name="endValue">The value to tween to</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>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)"> <member name="M:DG.Tweening.ShortcutExtensions.DOBlendableMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>Tweens a Transform's position BY the given value (as if you chained a <code>SetRelative</code>), <summary>Tweens a Transform's position BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableMove tweens to work together on the same target, in a way that allows other DOBlendableMove tweens to work together on the same target,

View File

@ -72,7 +72,9 @@ namespace DG.Tweening
#endif #endif
#if UNITY_5_3_OR_NEWER || UNITY_2017_1_OR_NEWER #if UNITY_5_3_OR_NEWER || UNITY_2017_1_OR_NEWER
#region CustomYieldInstructions (Unity 5.3 or Newer) #region Unity 5.3 or Newer
#region CustomYieldInstructions
/// <summary> /// <summary>
/// Returns a <see cref="CustomYieldInstruction"/> that waits until the tween is killed or complete. /// Returns a <see cref="CustomYieldInstruction"/> that waits until the tween is killed or complete.
@ -162,6 +164,46 @@ namespace DG.Tweening
} }
#endregion #endregion
#endregion
#endif
#if UNITY_2018_1_OR_NEWER
#region Unity 2018.1 or Newer
#region Material
/// <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 Tweener DOOffset(this Material target, Vector2 endValue, int propertyID, float duration)
{
if (!target.HasProperty(propertyID)) {
if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID);
return null;
}
return DOTween.To(() => target.GetTextureOffset(propertyID), x => target.SetTextureOffset(propertyID, x), endValue, duration).SetTarget(target);
}
/// <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 Tweener DOTiling(this Material target, Vector2 endValue, int propertyID, float duration)
{
if (!target.HasProperty(propertyID)) {
if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID);
return null;
}
return DOTween.To(() => target.GetTextureScale(propertyID), x => target.SetTextureScale(propertyID, x), endValue, duration).SetTarget(target);
}
#endregion
#endregion
#endif #endif
} }

View File

@ -66,6 +66,10 @@ namespace DG.Tweening.Core
{ {
LogWarning(string.Format("This material doesn't have a {0} property", propertyName)); LogWarning(string.Format("This material doesn't have a {0} property", propertyName));
} }
public static void LogMissingMaterialProperty(int propertyId)
{
LogWarning(string.Format("This material doesn't have a {0} property ID", propertyId));
}
public static void LogRemoveActiveTweenError(string errorInfo) public static void LogRemoveActiveTweenError(string errorInfo)
{ {

View File

@ -32,7 +32,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.2.170"; // Last version before modules: 1.1.755 public static readonly string Version = "1.2.175"; // Last version before modules: 1.1.755
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Options //////////////////////////////////// // Options ////////////////////////////////////

View File

@ -234,6 +234,19 @@ namespace DG.Tweening
} }
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);
} }
/// <summary>Tweens a Material's named color 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 Tweener DOColor(this Material target, Color endValue, int propertyID, float duration)
{
if (!target.HasProperty(propertyID)) {
if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID);
return null;
}
return DOTween.To(() => target.GetColor(propertyID), x => target.SetColor(propertyID, x), endValue, duration).SetTarget(target);
}
/// <summary>Tweens a Material's alpha color to the given value /// <summary>Tweens a Material's alpha color to the given value
/// (will have no effect unless your material supports transparency). /// (will have no effect unless your material supports transparency).
@ -258,6 +271,20 @@ namespace DG.Tweening
} }
return DOTween.ToAlpha(() => target.GetColor(property), x => target.SetColor(property, x), endValue, duration).SetTarget(target); return DOTween.ToAlpha(() => target.GetColor(property), x => target.SetColor(property, x), endValue, duration).SetTarget(target);
} }
/// <summary>Tweens a Material's alpha color with the given ID 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="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 Tweener DOFade(this Material target, float endValue, int propertyID, float duration)
{
if (!target.HasProperty(propertyID)) {
if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID);
return null;
}
return DOTween.ToAlpha(() => target.GetColor(propertyID), x => target.SetColor(propertyID, 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>
@ -272,6 +299,19 @@ namespace DG.Tweening
} }
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);
} }
/// <summary>Tweens a Material's named float 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 Tweener DOFloat(this Material target, float endValue, int propertyID, float duration)
{
if (!target.HasProperty(propertyID)) {
if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID);
return null;
}
return DOTween.To(() => target.GetFloat(propertyID), x => target.SetFloat(propertyID, x), endValue, duration).SetTarget(target);
}
/// <summary>Tweens a Material's texture offset to the given value. /// <summary>Tweens a Material's texture offset 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>
@ -330,6 +370,19 @@ namespace DG.Tweening
} }
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);
} }
/// <summary>Tweens a Material's named Vector 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 Tweener DOVector(this Material target, Vector4 endValue, int propertyID, float duration)
{
if (!target.HasProperty(propertyID)) {
if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID);
return null;
}
return DOTween.To(() => target.GetVector(propertyID), x => target.SetVector(propertyID, x), endValue, duration).SetTarget(target);
}
#endregion #endregion
@ -980,6 +1033,33 @@ namespace DG.Tweening
}, endValue, duration) }, endValue, duration)
.Blendable().SetTarget(target); .Blendable().SetTarget(target);
} }
/// <summary>Tweens a Material's named color property with the given ID to the given value,
/// in a way that allows other DOBlendableColor tweens to work together on the same target,
/// instead than fight each other as multiple DOColor would do.
/// Also stores the Material as the tween's target so it can be used for filtered operations</summary>
/// <param name="endValue">The value to tween to</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 Tweener DOBlendableColor(this Material target, Color endValue, int propertyID, float duration)
{
if (!target.HasProperty(propertyID)) {
if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID);
return null;
}
endValue = endValue - target.GetColor(propertyID);
Color to = new Color(0, 0, 0, 0);
return DOTween.To(() => to, x => {
#if COMPATIBLE
Color diff = x.value - to;
#else
Color diff = x - to;
#endif
to = x;
target.SetColor(propertyID, target.GetColor(propertyID) + diff);
}, endValue, duration)
.Blendable().SetTarget(target);
}
#endregion #endregion

View File

@ -30,7 +30,7 @@
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>..\bin\</OutputPath> <OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE;UNITY_EDITOR;UNITY_4_3;UNITY_4_6;UNITY_5;UNITY_2017_1_OR_NEWER</DefineConstants> <DefineConstants>TRACE;UNITY_EDITOR;UNITY_4_3;UNITY_4_6;UNITY_5;UNITY_2017_1_OR_NEWER;UNITY_2018_1_OR_NEWER</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile> <DocumentationFile>

View File

@ -1382,6 +1382,13 @@
<param name="property">The name of the material property to tween (like _Tint or _SpecColor)</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> <param name="duration">The duration of the tween</param>
</member> </member>
<member name="M:DG.Tweening.ShortcutExtensions.DOColor(UnityEngine.Material,UnityEngine.Color,System.Int32,System.Single)">
<summary>Tweens a Material's named color 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>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOFade(UnityEngine.Material,System.Single,System.Single)"> <member name="M:DG.Tweening.ShortcutExtensions.DOFade(UnityEngine.Material,System.Single,System.Single)">
<summary>Tweens a Material's alpha color to the given value <summary>Tweens a Material's alpha color to the given value
(will have no effect unless your material supports transparency). (will have no effect unless your material supports transparency).
@ -1396,6 +1403,14 @@
<param name="property">The name of the material property to tween (like _Tint or _SpecColor)</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> <param name="duration">The duration of the tween</param>
</member> </member>
<member name="M:DG.Tweening.ShortcutExtensions.DOFade(UnityEngine.Material,System.Single,System.Int32,System.Single)">
<summary>Tweens a Material's alpha color with the given ID 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="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>
</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>
@ -1403,6 +1418,13 @@
<param name="property">The name of the material property to tween</param> <param name="property">The name of the material property to tween</param>
<param name="duration">The duration of the tween</param> <param name="duration">The duration of the tween</param>
</member> </member>
<member name="M:DG.Tweening.ShortcutExtensions.DOFloat(UnityEngine.Material,System.Single,System.Int32,System.Single)">
<summary>Tweens a Material's named float 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>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOOffset(UnityEngine.Material,UnityEngine.Vector2,System.Single)"> <member name="M:DG.Tweening.ShortcutExtensions.DOOffset(UnityEngine.Material,UnityEngine.Vector2,System.Single)">
<summary>Tweens a Material's texture offset to the given value. <summary>Tweens a Material's texture offset 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>
@ -1436,6 +1458,13 @@
<param name="property">The name of the material property to tween</param> <param name="property">The name of the material property to tween</param>
<param name="duration">The duration of the tween</param> <param name="duration">The duration of the tween</param>
</member> </member>
<member name="M:DG.Tweening.ShortcutExtensions.DOVector(UnityEngine.Material,UnityEngine.Vector4,System.Int32,System.Single)">
<summary>Tweens a Material's named Vector 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>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOResize(UnityEngine.TrailRenderer,System.Single,System.Single,System.Single)"> <member name="M:DG.Tweening.ShortcutExtensions.DOResize(UnityEngine.TrailRenderer,System.Single,System.Single,System.Single)">
<summary>Tweens a TrailRenderer's startWidth/endWidth to the given value. <summary>Tweens a TrailRenderer's startWidth/endWidth to the given value.
Also stores the TrailRenderer as the tween's target so it can be used for filtered operations</summary> Also stores the TrailRenderer as the tween's target so it can be used for filtered operations</summary>
@ -1730,6 +1759,15 @@
<param name="property">The name of the material property to tween (like _Tint or _SpecColor)</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> <param name="duration">The duration of the tween</param>
</member> </member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableColor(UnityEngine.Material,UnityEngine.Color,System.Int32,System.Single)">
<summary>Tweens a Material's named color property with the given ID to the given value,
in a way that allows other DOBlendableColor tweens to work together on the same target,
instead than fight each other as multiple DOColor would do.
Also stores the Material as the tween's target so it can be used for filtered operations</summary>
<param name="endValue">The value to tween to</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>
</member>
<member name="M:DG.Tweening.ShortcutExtensions.DOBlendableMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)"> <member name="M:DG.Tweening.ShortcutExtensions.DOBlendableMoveBy(UnityEngine.Transform,UnityEngine.Vector3,System.Single,System.Boolean)">
<summary>Tweens a Transform's position BY the given value (as if you chained a <code>SetRelative</code>), <summary>Tweens a Transform's position BY the given value (as if you chained a <code>SetRelative</code>),
in a way that allows other DOBlendableMove tweens to work together on the same target, in a way that allows other DOBlendableMove tweens to work together on the same target,

Binary file not shown.

View File

@ -72,7 +72,9 @@ namespace DG.Tweening
#endif #endif
#if UNITY_5_3_OR_NEWER || UNITY_2017_1_OR_NEWER #if UNITY_5_3_OR_NEWER || UNITY_2017_1_OR_NEWER
#region CustomYieldInstructions (Unity 5.3 or Newer) #region Unity 5.3 or Newer
#region CustomYieldInstructions
/// <summary> /// <summary>
/// Returns a <see cref="CustomYieldInstruction"/> that waits until the tween is killed or complete. /// Returns a <see cref="CustomYieldInstruction"/> that waits until the tween is killed or complete.
@ -162,6 +164,46 @@ namespace DG.Tweening
} }
#endregion #endregion
#endregion
#endif
#if UNITY_2018_1_OR_NEWER
#region Unity 2018.1 or Newer
#region Material
/// <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 Tweener DOOffset(this Material target, Vector2 endValue, int propertyID, float duration)
{
if (!target.HasProperty(propertyID)) {
if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID);
return null;
}
return DOTween.To(() => target.GetTextureOffset(propertyID), x => target.SetTextureOffset(propertyID, x), endValue, duration).SetTarget(target);
}
/// <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 Tweener DOTiling(this Material target, Vector2 endValue, int propertyID, float duration)
{
if (!target.HasProperty(propertyID)) {
if (Debugger.logPriority > 0) Debugger.LogMissingMaterialProperty(propertyID);
return null;
}
return DOTween.To(() => target.GetTextureScale(propertyID), x => target.SetTextureScale(propertyID, x), endValue, duration).SetTarget(target);
}
#endregion
#endregion
#endif #endif
} }