A game about forced loneliness, made by TACStudios
1using System.Linq; 2using UnityEditor; 3using UnityEngine; 4 5namespace Unity.VisualScripting 6{ 7 [Widget(typeof(SubgraphUnit))] 8 public class SuperUnitWidget : NestrerUnitWidget<SubgraphUnit>, IDragAndDropHandler 9 { 10 public SuperUnitWidget(FlowCanvas canvas, SubgraphUnit unit) : base(canvas, unit) { } 11 12 protected override NodeColorMix baseColor 13 { 14 get 15 { 16 // TODO: Move to descriptor for optimization 17 using (var recursion = Recursion.New(1)) 18 { 19 if (unit.nest.graph?.GetUnitsRecursive(recursion).OfType<IEventUnit>().Any() ?? false) 20 { 21 return NodeColor.Green; 22 } 23 } 24 25 return base.baseColor; 26 } 27 } 28 29 public DragAndDropVisualMode dragAndDropVisualMode => DragAndDropVisualMode.Generic; 30 31 public bool AcceptsDragAndDrop() 32 { 33 return DragAndDropUtility.Is<ScriptGraphAsset>() && FlowDragAndDropUtility.AcceptsScript(graph); 34 } 35 36 public void PerformDragAndDrop() 37 { 38 UndoUtility.RecordEditedObject("Drag & Drop Macro"); 39 unit.nest.source = GraphSource.Macro; 40 unit.nest.macro = DragAndDropUtility.Get<ScriptGraphAsset>(); 41 unit.nest.embed = null; 42 unit.Define(); 43 GUI.changed = true; 44 } 45 46 public void UpdateDragAndDrop() 47 { 48 } 49 50 public void DrawDragAndDropPreview() 51 { 52 GraphGUI.DrawDragAndDropPreviewLabel(new Vector2(edgePosition.x, outerPosition.yMax), "Replace with: " + DragAndDropUtility.Get<ScriptGraphAsset>().name, typeof(ScriptGraphAsset).Icon()); 53 } 54 55 public void ExitDragAndDrop() 56 { 57 } 58 } 59}