rokojori_action_library/Runtime/Actions/Visual/SetMaterial.cs

47 lines
661 B
C#
Raw Normal View History

2025-05-27 06:51:48 +00:00
using Godot;
namespace Rokojori
{
[Tool]
[GlobalClass ]
public partial class SetMaterial : Action
{
[Export]
public Node3D target;
[Export]
public Material material;
[Export]
public MaterialSlot slot = MaterialSlot.None;
[Export]
public int index = 0;
2025-12-11 14:47:57 +00:00
2025-05-27 06:51:48 +00:00
protected override void _OnTrigger()
{
2025-12-11 14:47:57 +00:00
if ( target == null )
2025-05-27 06:51:48 +00:00
{
return;
}
var msc = MaterialSurfaceContainer.From( target, index );
2025-12-11 14:47:57 +00:00
if ( material == null )
{
msc.RemoveMaterialInSlot( slot );
}
else
{
msc.SetMaterialInSlot( slot, material );
}
2025-05-27 06:51:48 +00:00
}
}
}