No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StateUnitWidget.cs 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using UnityEditor;
  2. using UnityEngine;
  3. namespace Unity.VisualScripting
  4. {
  5. [Widget(typeof(StateUnit))]
  6. public class StateUnitWidget : NestrerUnitWidget<StateUnit>, IDragAndDropHandler
  7. {
  8. public StateUnitWidget(FlowCanvas canvas, StateUnit unit) : base(canvas, unit) { }
  9. public DragAndDropVisualMode dragAndDropVisualMode => DragAndDropVisualMode.Generic;
  10. public bool AcceptsDragAndDrop()
  11. {
  12. return DragAndDropUtility.Is<StateGraphAsset>();
  13. }
  14. public void PerformDragAndDrop()
  15. {
  16. UndoUtility.RecordEditedObject("Drag & Drop Macro");
  17. unit.nest.source = GraphSource.Macro;
  18. unit.nest.macro = DragAndDropUtility.Get<StateGraphAsset>();
  19. unit.nest.embed = null;
  20. unit.Define();
  21. GUI.changed = true;
  22. }
  23. public void UpdateDragAndDrop()
  24. {
  25. }
  26. public void DrawDragAndDropPreview()
  27. {
  28. GraphGUI.DrawDragAndDropPreviewLabel(new Vector2(edgePosition.x, outerPosition.yMax), "Replace with: " + DragAndDropUtility.Get<StateGraphAsset>().name, typeof(StateGraphAsset).Icon());
  29. }
  30. public void ExitDragAndDrop()
  31. {
  32. }
  33. }
  34. }