UnityGame/Library/PackageCache/com.unity.visualscripting/Editor/VisualScripting.State/Flow/FlowGraphContextStateExtension.cs

26 lines
939 B
C#
Raw Normal View History

2024-10-27 10:53:47 +03:00
namespace Unity.VisualScripting
{
[GraphContextExtension(typeof(FlowGraphContext))]
public sealed class FlowGraphContextStateExtension : GraphContextExtension<FlowGraphContext>
{
public FlowGraphContextStateExtension(FlowGraphContext context) : base(context) { }
public override bool AcceptsDragAndDrop()
{
return DragAndDropUtility.Is<StateGraphAsset>();
}
public override void PerformDragAndDrop()
{
var statemacro = DragAndDropUtility.Get<StateGraphAsset>();
var stateUnit = new StateUnit(statemacro);
context.canvas.AddUnit(stateUnit, DragAndDropUtility.position);
}
public override void DrawDragAndDropPreview()
{
GraphGUI.DrawDragAndDropPreviewLabel(DragAndDropUtility.offsetedPosition, DragAndDropUtility.Get<StateGraphAsset>().name, typeof(StateGraphAsset).Icon());
}
}
}