public override bool AcceptsDragAndDrop() { if (DragAndDropUtility.Is <ScriptGraphAsset>()) { return(FlowDragAndDropUtility.AcceptsScript(graph)); } return(DragAndDropUtility.Is <UnityObject>() && !DragAndDropUtility.Is <IMacro>() && CanDetermineDraggedInput(DragAndDropUtility.Get <UnityObject>()) || EditorVariablesUtility.isDraggingVariable); }
public override void DrawDragAndDropPreview() { if (DragAndDropUtility.Is <ScriptGraphAsset>()) { GraphGUI.DrawDragAndDropPreviewLabel(DragAndDropUtility.offsetedPosition, DragAndDropUtility.Get <ScriptGraphAsset>().name, typeof(ScriptGraphAsset).Icon()); } else if (DragAndDropUtility.Is <StateGraphAsset>()) { GraphGUI.DrawDragAndDropPreviewLabel(DragAndDropUtility.offsetedPosition, DragAndDropUtility.Get <StateGraphAsset>().name, typeof(StateGraphAsset).Icon()); } }
public override void PerformDragAndDrop() { if (DragAndDropUtility.Is <ScriptGraphAsset>()) { var flowMacro = DragAndDropUtility.Get <ScriptGraphAsset>(); var flowState = new FlowState(flowMacro); AddState(flowState, DragAndDropUtility.position); } else if (DragAndDropUtility.Is <StateGraphAsset>()) { var asset = DragAndDropUtility.Get <StateGraphAsset>(); var superState = new SuperState(asset); AddState(superState, DragAndDropUtility.position); } }
public override void DrawDragAndDropPreview() { if (DragAndDropUtility.Is <ScriptGraphAsset>()) { GraphGUI.DrawDragAndDropPreviewLabel(DragAndDropUtility.offsetedPosition, DragAndDropUtility.Get <ScriptGraphAsset>().name, typeof(ScriptGraphAsset).Icon()); } else if (DragAndDropUtility.Is <GameObject>()) { var gameObject = DragAndDropUtility.Get <GameObject>(); GraphGUI.DrawDragAndDropPreviewLabel(DragAndDropUtility.offsetedPosition, gameObject.name + "...", gameObject.Icon()); } else if (DragAndDropUtility.Is <UnityObject>()) { var obj = DragAndDropUtility.Get <UnityObject>(); var type = obj.GetType(); GraphGUI.DrawDragAndDropPreviewLabel(DragAndDropUtility.offsetedPosition, type.HumanName() + "...", type.Icon()); } else if (EditorVariablesUtility.isDraggingVariable) { var kind = EditorVariablesUtility.kind; var name = EditorVariablesUtility.declaration.name; string label; if (e.alt) { label = $"Set {name}"; } else if (e.shift) { label = $"Check if {name} is defined"; } else { label = $"Get {name}"; } GraphGUI.DrawDragAndDropPreviewLabel(DragAndDropUtility.offsetedPosition, label, BoltCore.Icons.VariableKind(kind)); } }
public bool AcceptsDragAndDrop() { return(DragAndDropUtility.Is <StateGraphAsset>()); }
public override bool AcceptsDragAndDrop() { return(DragAndDropUtility.Is <ScriptGraphAsset>() || DragAndDropUtility.Is <StateGraphAsset>()); }
public bool AcceptsDragAndDrop() { return(DragAndDropUtility.Is <ScriptGraphAsset>() && FlowDragAndDropUtility.AcceptsScript(graph)); }
public override void PerformDragAndDrop() { if (DragAndDropUtility.Is <ScriptGraphAsset>()) { var flowMacro = DragAndDropUtility.Get <ScriptGraphAsset>(); var superUnit = new SuperUnit(flowMacro); AddUnit(superUnit, DragAndDropUtility.position); } else if (DragAndDropUtility.Is <UnityObject>()) { var uo = DragAndDropUtility.Get <UnityObject>(); var type = uo.GetType(); var filter = UnitOptionFilter.Any; filter.Literals = false; filter.Expose = false; var options = GetNewUnitOptions(filter); var root = new List <object>(); if (!uo.IsSceneBound() || reference.serializedObject.IsSceneBound()) { if (uo == reference.self) { root.Add(new UnitOption <This>(new This())); } root.Add(new LiteralOption(new Literal(type, uo))); } if (uo is MonoScript script) { var scriptType = script.GetClass(); if (scriptType != null) { root.Add(scriptType); } } else { root.Add(type); } if (uo is GameObject) { root.AddRange(uo.GetComponents <Component>().Select(c => c.GetType())); } options.rootOverride = root.ToArray(); NewUnit(DragAndDropUtility.position, options, (unit) => { // Try to assign a correct input var compatibleInput = unit.CompatibleValueInput(type); if (compatibleInput == null) { return; } if (uo.IsSceneBound()) { if (reference.self == uo.GameObject()) { // The component is owned by the same game object as the graph. if (compatibleInput.nullMeansSelf) { compatibleInput.SetDefaultValue(null); } else { var self = new This(); self.position = unit.position + new Vector2(-150, 19); graph.units.Add(self); self.self.ConnectToValid(compatibleInput); } } else if (reference.serializedObject.IsSceneBound()) { // The component is from another object from the same scene compatibleInput.SetDefaultValue(uo.ConvertTo(compatibleInput.type)); } else { throw new NotSupportedException("Cannot determine compatible input from dragged Unity object."); } } else { compatibleInput.SetDefaultValue(uo.ConvertTo(compatibleInput.type)); } }); } else if (EditorVariablesUtility.isDraggingVariable) { var kind = EditorVariablesUtility.kind; var declaration = EditorVariablesUtility.declaration; UnifiedVariableUnit unit; if (e.alt) { unit = new SetVariable(); } else if (e.shift) { unit = new IsVariableDefined(); } else { unit = new GetVariable(); } unit.kind = kind; AddUnit(unit, DragAndDropUtility.position); unit.name.SetDefaultValue(declaration.name); } }