mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-14 13:23:47 +00:00
Added GTWeen
This commit is contained in:
parent
457998788e
commit
2036e4e748
152 changed files with 5889 additions and 7 deletions
|
|
@ -0,0 +1,92 @@
|
|||
using Godot;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class ShaderMaterialExtensions
|
||||
{
|
||||
public static GTween TweenPropertyInt(this ShaderMaterial target, StringName property, int to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GetShaderParameter(property).AsInt32(),
|
||||
current => target.SetShaderParameter(property, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPropertyFloat(this ShaderMaterial target, StringName property, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GetShaderParameter(property).AsSingle(),
|
||||
current => target.SetShaderParameter(property, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPropertyVector2(this ShaderMaterial target, StringName property, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.GetShaderParameter(property).AsVector2(),
|
||||
current => target.SetShaderParameter(property, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPropertyVector2I(this ShaderMaterial target, StringName property, Vector2I to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.GetShaderParameter(property).AsVector2I(),
|
||||
current => target.SetShaderParameter(property, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPropertyColor(this ShaderMaterial target, StringName property, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.GetShaderParameter(property).AsColor(),
|
||||
current => target.SetShaderParameter(property, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPropertyColorRgb(this ShaderMaterial target, StringName property, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.GetShaderParameter(property).AsColor(),
|
||||
current => target.SetShaderParameter(
|
||||
property,
|
||||
new Color(current.R, current.G, current.B, target.GetShaderParameter(property).AsColor().A)
|
||||
),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPropertyColorAlpha(this ShaderMaterial target, StringName property, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GetShaderParameter(property).AsColor().A,
|
||||
current =>
|
||||
{
|
||||
Color previous = target.GetShaderParameter(property).AsColor();
|
||||
target.SetShaderParameter(property, new Color(previous.R, previous.G, previous.B, current));
|
||||
},
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue