public ExampleGraphView(EditorWindow editor, ref GraphAsset asset) { graphAsset = asset; editorWindow = editor; //AddElement(new ExampleNode()); //ノードの追加 //諸々の設定 this.StretchToParentSize(); contentDragger = new ContentDragger(); selectionDragger = new SelectionDragger(); SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale); this.AddManipulator(new ContextualMenuManipulator(OnContextMenuPopulate)); this.AddManipulator(contentDragger); this.AddManipulator(selectionDragger); //this.AddManipulator(new RectangleSelector()); //右クリックでのメニューの表示 searchWindow = ScriptableObject.CreateInstance <SearchMenuWindow>(); searchWindow.Init(this, editor, ref graphAsset); nodeCreationRequest += context => { SearchWindow.Open(new SearchWindowContext(context.screenMousePosition), searchWindow); }; }
public override void OnInspectorGUI() { GraphAsset asset = target as GraphAsset; DrawDefaultInspector(); EditorGUILayout.HelpBox("The GraphAsset is not supported anymore", MessageType.Warning); }
public GraphEditorElement(GraphAsset graphAsset) { m_GraphAsset = graphAsset; style.flexGrow = 1; style.overflow = Overflow.Hidden; this.AddManipulator(new ContextualMenuManipulator(OnContextMenuPopulate)); m_Nodes = new List <NodeElement>(); foreach (var node in graphAsset.nodes) { CreateNodeElement(node); } m_Edges = new List <EdgeElement>(); foreach (var node in m_Nodes) { foreach (var edge in node.serializableNode.edges) { CreateEdgeElement(edge, node, m_Nodes); } } }
public static void SetGraphAsset(GraphAsset asset) { if (Resources.FindObjectsOfTypeAll <GraphEditorWindow>()[0]) { editor = Resources.FindObjectsOfTypeAll <GraphEditorWindow>()[0]; } else { editor = Init(); } if (asset != GraphEditor.asset) { GraphEditor.ClearSelection(); } if (GraphEditor.asset) { GraphEditor.asset.position = GraphEditor.scroll; GraphEditor.asset.SaveData(); } if (asset) { asset.Validate(); GraphEditor.scroll = asset.position; } GraphEditor.asset = asset; SetGraph(asset ? asset.graph : null); }
public void SetLoadData(GraphAsset asset) { foreach (var save in asset.data) { //ここでfileNameの入力 LoadTextDataFile(save, save.position, false, save.pathName); } }
public void Init(ExampleGraphView graph, EditorWindow edit, ref GraphAsset asset) { graphView = graph; editorWindow = edit; foreach (var node in asset.data) { saveData = node; } }
public void Initialize(GraphAsset graphAsset) { m_GraphAsset = graphAsset; VisualElement root = this.rootVisualElement; m_Element = new GraphEditorElement(graphAsset); // アセットを渡す root.Add(m_Element); }
private void OnGUI() { float singleLineHeight = EditorGUIUtility.singleLineHeight; Vector2 offset = new Vector2(160, singleLineHeight * 5); Rect viewRect = this.position; viewRect.position = Vector2.zero; viewRect.width -= (offset.x + 2); // main graph.OnGUI(viewRect); // detail Rect detail = viewRect.SetWidth(offset.x); detail.position = Vector2.zero; detail = detail.OffsetX(position.width - offset.x); detail.height -= (offset.y + 2); graph.OnGUIDetail(detail); // save&load Rect assetIO = new Rect(detail.position, offset); assetIO = assetIO.OffsetY(position.height - offset.y); GUILayout.BeginArea(assetIO); float move = singleLineHeight * 1.2f; GUILayout.Label("Asset path:"); filePath = GUILayout.TextField(filePath); if (GUILayout.Button("Save")) { GraphAsset asset = CreateInstance <GraphAsset>(); if (graph.Save(asset)) { AssetDatabase.CreateAsset(asset, filePath); EditorUtility.SetDirty(asset); AssetDatabase.SaveAssets(); } } if (GUILayout.Button("Load")) { GraphAsset data = AssetDatabase.LoadAssetAtPath <GraphAsset>(filePath); if (data != null) { Graph <GraphAsset, NodeData, RouteData> newGraph = null; if (Graph <GraphAsset, NodeData, RouteData> .Load(data, out newGraph)) { graph = newGraph; } } } GUILayout.EndArea(); }
public static MacroNode AddMacro(GraphAsset reference, Vector2 position = default(Vector2)) { if (!GraphEditor.graph) { return(null); } UndoManager.RecordObject(GraphEditor.asset, string.Format("{0} Add Graph", GraphEditor.asset.name)); set_dirty = true; return(GraphEditor.graph.AddMacro(reference, position)); }
public void Init(GraphAsset asset) { graphAsset = asset; graphView = new ExampleGraphView(this, ref graphAsset); rootVisualElement.Add(graphView); if (asset.data.Count != 0) { graphView.getSearchWindow.SetLoadData(graphAsset); } }
public static bool GraphAssetOpenEditor(int instance_ID, int line) { GraphAsset asset = EditorUtility.InstanceIDToObject(instance_ID) as GraphAsset; if (asset) { GraphEditorWindow.OpenEditor(asset); return(true); } return(false); }
protected virtual void Awake() { storedActionQueue = new Queue <GOAPAction>(); actionQueue = new Queue <GOAPAction>(); Provider = GetComponent <IGOAP>(); Planner = new GOAPPlanner(); FSM = new GOAPFSM(); GraphAsset = GraphAsset.Clone() as GOAPGraphAsset; T_Graph.Initialize(this); Goals = Goals.OrderByDescending(goal => goal.Priority).ToList(); }
public static void RecordObject(Object target, string name) { if (Application.isPlaying || target == null) { return; } //new log("RecordObject: " + name); if (target is GraphAsset) { asset_undo = (GraphAsset)target; } Undo.RecordObject(target, name); }
private void OnSelectionChange() { if (Selection.activeGameObject) { GraphController controller = Selection.activeGameObject.GetComponent <GraphController>(); if (controller) { GraphAsset asset = controller.graph; if (asset && GraphEditor.graph != asset.graph) { SetGraphAsset(GraphEditor.asset); } } } }
public GraphEditorElement(GraphAsset graphAsset) { m_GraphAsset = graphAsset; style.flexGrow = 1; style.overflow = Overflow.Hidden; this.AddManipulator(new ContextualMenuManipulator(OnContextMenuPopulate)); m_Nodes = new List <NodeElement>(); foreach (var node in graphAsset.nodes) { CreateNodeElement(node); } }
private void ShowMenu(GraphAsset asset, ParameterType parameter_type) { GenericMenu generic_menu = new GenericMenu(); if (parameter_type == ParameterType.Input) { generic_menu.AddItem(new GUIContent("Input"), false, () => { UndoManager.RecordObject(target, "Add new parameter"); asset.graph.AddCustomParameter("new InputPort", typeof(ParameterInput), parameter_type); GraphEditor.current_validate = true; CreateReorderableLists(); }); } if (parameter_type == ParameterType.Output) { generic_menu.AddItem(new GUIContent("Output"), false, () => { UndoManager.RecordObject(target, "Add new parameter"); asset.graph.AddCustomParameter("new OutputPort", typeof(ParameterOutput), parameter_type); GraphEditor.current_validate = true; CreateReorderableLists(); }); } foreach (Type type in EditorHandler.GetConstantTypesCurrentInstance().current_types) { if (!type.IsStatic() && !type.IsGenericType) { string type_path = type.GetTypePath(true); //List generic_menu.AddItem(new GUIContent("List/" + type_path), false, (object obj) => { UndoManager.RecordObject(target, "Add new parameter"); asset.graph.AddParameter(string.Format("new {0}", type.GetTypeName()), typeof(List <>).MakeGenericType(type), parameter_type); GraphEditor.current_validate = true; CreateReorderableLists(); }, type); generic_menu.AddItem(new GUIContent(type_path), false, (object obj) => { UndoManager.RecordObject(target, "Add new parameter"); asset.graph.AddParameter(string.Format("new {0}", type.GetTypeName()), type, parameter_type); GraphEditor.current_validate = true; CreateReorderableLists(); }, type); } } generic_menu.ShowAsContext(); }
public void ExecuteGraph_Should_Succeed_WithGraphAsset() { var graphType = Substitute.For <IExecutableGraphType <string> >(); var graph = new GraphModel(graphType); var nodeType = new SourceNode("test"); var node = nodeType.CreateNode(); graph.AddNode(node); var graphAsset = GraphAsset.Create(graph); var args = "test"; var result = GraphExecutor.ExecuteGraph(graphAsset, args); Assert.That(result, Is.Not.Null); graphType.Received().Execute(graph, args); }
public Graph(GraphAsset graphAsset) { nodes = new List <Node>(); foreach (var serializableNode in graphAsset.nodes) { Node node = new Node(); nodes.Add(node); } for (int i = 0; i < graphAsset.nodes.Count; i++) { var serializableNode = graphAsset.nodes[i]; foreach (var serializableEdge in serializableNode.edges) { nodes[i].ConnectTo(nodes[serializableEdge.toId]); } } }
public void ExecuteGraphAsync_Should_Succeed_WithGraphAsset() { var graphType = Substitute.For <IExecutableAsyncGraphType <string> >(); graphType.ExecuteAsync(Arg.Any <GraphModel>(), Arg.Any <string>()).Returns(Task.FromResult(Substitute.For <IGraphExecutionResult>())); var graph = new GraphModel(graphType); var nodeType = new SourceNode("test"); var node = nodeType.CreateNode(); graph.AddNode(node); var graphAsset = GraphAsset.Create(graph); var args = "test"; var result = GraphExecutor.ExecuteGraphAsync(graphAsset, args); Assert.That(result, Is.Not.Null); graphType.Received().ExecuteAsync(graph, args); }
public void SetDataAsset(ref GraphAsset asset) { asset.data.Add(saveData); dataLoadFlag = false; }
public override void OnInspectorGUI() { GraphController controller = (GraphController)target; GraphAsset graph = controller.graph; OnEnableAction on_enable = controller.on_enable; bool once = controller.once; float seconds = controller.seconds; OnDisableAction on_disable = controller.on_disable; controller.CopyParameters(); graph = (GraphAsset)EditorGUILayout.ObjectField(new GUIContent("Graph"), controller.graph, typeof(GraphAsset), false); if (controller.graph != graph) { controller.OnGraphChange(controller.graph, graph); } if (controller.graph) { on_enable = (OnEnableAction)EditorGUILayout.EnumPopup(new GUIContent("OnEnable"), controller.on_enable); switch (on_enable) { case OnEnableAction.DoNothing: case OnEnableAction.PlayGraph: if (height != 0.0f) { height = 0.0f; EditorUtils.RepaintInspector(); } seconds = 0.0f; break; case OnEnableAction.WaitForSeconds: GUILayout.BeginVertical("Box"); if (height != EditorGUIUtility.singleLineHeight) { height = Mathf.MoveTowards(height, EditorGUIUtility.singleLineHeight, 1.0f); EditorUtils.RepaintInspector(); } once = EditorGUILayout.Toggle(new GUIContent("Only Once"), controller.once, GUILayout.Height(height)); seconds = EditorGUILayout.FloatField(new GUIContent("Seconds"), controller.seconds, GUILayout.Height(height)); GUILayout.EndVertical(); break; } on_disable = (OnDisableAction)EditorGUILayout.EnumPopup(new GUIContent("OnDisable"), controller.on_disable); GUILayout.BeginHorizontal(); if (GUILayout.Button("Ping to Asset")) { EditorGUIUtility.PingObject(controller.graph); } if (GUILayout.Button("Open in Editor")) { GraphEditorWindow.OpenEditor(controller.graph); } GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal("RL Header"); { GUILayout.Space(15.0f); GUILayout.BeginVertical(); { foldout = EditorGUILayout.Foldout(foldout, new GUIContent(string.Format("Variables [{0}]", controller.properties.Values.Where(p => p.is_public).Count()))); } GUILayout.EndVertical(); if (GUILayout.Toggle(debug, debug ? "Debug" : "Normal", (GUIStyle)"minibutton") != debug) { debug = !debug; } } GUILayout.EndHorizontal(); if (foldout) { GUILayout.BeginHorizontal("RL Background", GUILayout.MinHeight(10.0f)); { GUILayout.Space(10.0f); GUILayout.BeginVertical(); { foreach (VariableObject property in controller.properties.Values.ToList()) { if (property.is_public || debug) { object last_value = property.GetValue(); object new_value = GUIDraw.AnyField(last_value, property.valueType, debug ? property.name + string.Format(" (ID = {0}, Type = {1})", property.id, property.valueType.GetTypeName(true, true)) : property.name); if (new_value != last_value) { UndoManager.RecordObject(target, "Change Value"); property.SetValue(new_value); } } } } GUILayout.Space(5.0f); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } if (GUI.changed) { UndoManager.RecordObject(target, "GraphController Inspector"); controller.graph = graph; controller.on_enable = on_enable; controller.once = once; controller.seconds = seconds; controller.on_disable = on_disable; UndoManager.SetDirty(target); } }
private void InputGUI() { Vector2 delta = current.delta; switch (current.type) { case EventType.MouseDown: GraphEditor.mouse_down_position = GraphEditor.mouse_position; switch (current.button) { case 0: if (current.alt) { break; } if (GraphEditor.hover_node) { if (current.clickCount >= 2) { if (GraphEditor.hover_node is MacroNode) { SetGraphAsset(((MacroNode)GraphEditor.hover_node).reference); current.Use(); return; } else { EditorUtils.OpenScriptByType(GraphEditor.hover_node.type); current.Use(); } } if (GraphEditor.hover_port) { if (current.control) { if (GraphEditor.hover_port is OutputAction) { UndoManager.RecordObject(GraphEditor.asset, string.Format("{0} Add Branch", GraphEditor.asset.name)); set_dirty = true; QuickPlugPort(GraphEditor.hover_port, AddNode <Branch>(GraphEditor.mouse_position / GraphEditor.zoom - GraphEditor.scroll + new Vector2(60.0f, 0.0f))); } } else { if (current.shift) { GraphEditor.can_drag_node = false; GraphEditor.can_drag_port = false; if (GraphEditor.hover_port is IPlug) { UndoManager.RecordObject(GraphEditor.asset, string.Format("{0} > {1}: {2} Unplug", GraphEditor.asset.name, GraphEditor.hover_node.name, GraphEditor.hover_port.name)); set_dirty = true; ((IPlug)GraphEditor.hover_port).Unplug(); } current.Use(); } else { GraphEditor.can_drag_node = false; GraphEditor.can_drag_port = true; SelectOnlyNode(GraphEditor.hover_node); current.Use(); } } } else { if (current.shift) { if (GraphEditor.hover_node.is_selected) { GraphEditor.can_drag_node = false; DeselectNode(GraphEditor.hover_node); current.Use(); } else { GraphEditor.can_drag_node = true; SelectNode(GraphEditor.hover_node); current.Use(); } } else { if (GraphEditor.hover_node.is_selected) { GraphEditor.can_drag_node = true; } else { GraphEditor.can_drag_node = true; SelectOnlyNode(GraphEditor.hover_node); current.Use(); } } } } else if (editable_area.Contains(GraphEditor.mouse_position)) { GraphEditor.can_select = true; } break; case 1: break; case 2: break; } break; case EventType.MouseUp: switch (current.button) { case 0: if (GraphEditor.can_select && GraphEditor.is_select) { Rect select_box_in_scroll = new Rect(select_box.position / target_zoom, select_box.size / target_zoom); List <Node> nodes = GraphEditor.graph.nodes.Where((n) => select_box_in_scroll.Overlaps(n.nodeRect)).ToList(); if (current.shift) { foreach (Node node in nodes) { if (node.is_selected) { DeselectNode(node); } else { SelectNode(node); } } current.Use(); } else { ClearSelection(); SelectNodes(nodes); current.Use(); } } else { if (GraphEditor.hover_node) { if (GraphEditor.is_drag) { if (GraphEditor.drag_port) { if (GraphEditor.hover_port) { PlugPort(GraphEditor.drag_port, GraphEditor.hover_port); } else { QuickPlugPort(GraphEditor.drag_port, GraphEditor.hover_node); } current.Use(); } } else { if (!current.shift) { if (GraphEditor.selection.Count > 1) { SelectOnlyNode(GraphEditor.hover_node); current.Use(); } } } } else if (!GraphEditor.is_scrolling) { ClearSelection(); } if (GraphEditor.drag_port && !GraphEditor.hover_node) { InputAction in_act = GraphEditor.drag_port as InputAction; OutputAction out_act = GraphEditor.drag_port as OutputAction; IInputValue in_value = GraphEditor.drag_port as IInputValue; IOutputValue out_value = GraphEditor.drag_port as IOutputValue; if (in_act != null) { GraphEditor.waiting_for_new_node = true; AdvancedSearchWindow.Init(GraphEditor.mouse_position, "#tag:in void"); } else if (out_act != null) { GraphEditor.waiting_for_new_node = true; AdvancedSearchWindow.Init(GraphEditor.mouse_position, "#tag:out void"); } else if (in_value != null) { GraphEditor.waiting_for_new_node = true; AdvancedSearchWindow.Init(GraphEditor.mouse_position, "#tag:out " + in_value.valueType.GetTypeName(false, true)); } else if (out_value != null) { GraphEditor.waiting_for_new_node = true; AdvancedSearchWindow.Init(GraphEditor.mouse_position, "#tag:in " + out_value.valueType.GetTypeName(false, true)); } } } GraphEditor.can_select = false; GraphEditor.is_select = false; GraphEditor.is_scrolling = false; GraphEditor.hover_node = null; GraphEditor.drag_node = null; if (!GraphEditor.waiting_for_new_node) { GraphEditor.is_drag = false; GraphEditor.drag_port = null; GraphEditor.can_drag_port = false; } GraphEditor.can_drag_node = false; break; case 1: if (!GraphEditor.is_drag) { AdvancedSearchWindow.Init(GraphEditor.mouse_position); current.Use(); } GraphEditor.is_drag = false; break; case 2: break; } break; case EventType.MouseDrag: switch (current.button) { case 0: if (current.alt) { GraphEditor.is_drag = true; GraphEditor.is_scrolling = true; GraphEditor.scroll += delta; break; } if (!GraphEditor.is_drag) { if (GraphEditor.can_drag_port && GraphEditor.hover_port) { GraphEditor.is_drag = true; GraphEditor.can_drag_node = false; GraphEditor.drag_port = GraphEditor.hover_port; } if (GraphEditor.can_drag_node && GraphEditor.hover_node) { GraphEditor.is_drag = true; GraphEditor.can_drag_port = false; GraphEditor.drag_node = GraphEditor.hover_node; } } // ... if (GraphEditor.is_drag) { if (GraphEditor.drag_node) { foreach (Node node in GraphEditor.selection) { node.position += delta; } } } else { if (GraphEditor.can_select) { GraphEditor.is_select = true; } } break; case 1: GraphEditor.is_drag = true; GraphEditor.is_scrolling = true; GraphEditor.scroll += delta; break; case 2: GraphEditor.is_drag = true; GraphEditor.is_scrolling = true; GraphEditor.scroll += delta; break; } break; case EventType.ScrollWheel: if (!GraphEditor.is_drag) { float zoom_delta = 0.1f; zoom_delta = current.delta.y < 0.0f ? zoom_delta : -zoom_delta; target_zoom += zoom_delta; target_zoom = Mathf.Clamp(target_zoom, 0.2f, 1.0f); } break; case EventType.ValidateCommand: switch (Event.current.commandName) { case ("Delete"): DeleteSelectedNodes(); current.Use(); break; case ("Duplicate"): DuplicateSelectedNodes(); current.Use(); break; case ("SelectAll"): if (GraphEditor.selection.Count == GraphEditor.graph.nodeCount) { ClearSelection(); current.Use(); } else { SelectNodes(GraphEditor.graph.nodes); current.Use(); } break; } break; case EventType.DragUpdated: case EventType.DragPerform: if (DragAndDrop.objectReferences.Length > 0) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (current.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); GenericMenu generic_menu = new GenericMenu(); Type type; string type_name; foreach (UnityObject drag_obj in DragAndDrop.objectReferences) { if (drag_obj == null) { continue; } if (drag_obj is GraphAsset) { GraphAsset m_asset = (GraphAsset)drag_obj; if (m_asset) { generic_menu.AddItem(new GUIContent(string.Format("Add {0} as Macro", m_asset.title.IsNullOrEmpty() ? m_asset.name : m_asset.title)), false, (obj) => { AddMacro(m_asset, (Vector2)obj); }, GraphEditor.mouse_position - GraphEditor.scroll); } } else if (drag_obj is MonoScript) { MonoScript script = (MonoScript)drag_obj; if (script) { type = script.GetClass(); type_name = type.GetTypeName(); generic_menu.AddItem(new GUIContent(string.Format("{0}/Expose {0} members", type_name)), false, (obj) => { AddCustomNode <ReflectedObjectNode>((Vector2)obj, true, type); }, GraphEditor.mouse_position - GraphEditor.scroll); generic_menu.AddSeparator(string.Format("{0}/", type_name)); AddTypeMethodsToMenu(generic_menu, type, type_name); if (type.IsSubclassOf(typeof(Node)) && !type.IsAbstract && !type.IsGenericType) { generic_menu.AddItem(new GUIContent(string.Format("Add {0} as Node", type_name)), false, (obj) => { AddNode(type, (Vector2)obj); }, GraphEditor.mouse_position - GraphEditor.scroll); } } } if (drag_obj is GraphAsset || drag_obj is MonoScript) { generic_menu.AddSeparator(""); } type = drag_obj.GetType(); type_name = type.GetTypeName(); generic_menu.AddItem(new GUIContent(string.Format("Expose {0} members", type_name)), false, (obj) => { AddCustomNode <ReflectedObjectNode>((Vector2)obj, true, type); }, GraphEditor.mouse_position - GraphEditor.scroll); AddTypeMethodsToMenu(generic_menu, type, type_name); } DragAndDrop.PrepareStartDrag(); generic_menu.ShowAsContext(); } } break; case (EventType.KeyDown): switch (current.keyCode) { case KeyCode.Space: if (!current.control) { AdvancedSearchWindow.Init(position.size / 2.0f); current.Use(); } break; case KeyCode.Delete: DeleteSelectedNodes(); current.Use(); break; case KeyCode.Home: target_zoom = 1.0f; GraphEditor.scroll = Vector2.zero; current.Use(); break; case KeyCode.PageDown: GraphEditor.scroll -= new Vector2(0.0f, position.height); current.Use(); break; case KeyCode.PageUp: GraphEditor.scroll += new Vector2(0.0f, position.height); current.Use(); break; } break; } }
public static void OpenEditor(GraphAsset asset) { editor = Init(); SetGraphAsset(asset); }
private void CreateReorderableLists() { GraphAsset asset = (GraphAsset)target; variable_list = new ReorderableList(asset.graph.variableParameters, typeof(Parameter), true, true, true, true); input_list = new ReorderableList(asset.graph.inputParameters, typeof(Parameter), true, true, true, true); output_list = new ReorderableList(asset.graph.outputParameters, typeof(Parameter), true, true, true, true); variable_list.drawHeaderCallback = rect => { EditorGUI.LabelField(rect, "Variables Parameters"); }; input_list.drawHeaderCallback = rect => { EditorGUI.LabelField(rect, "Input Parameters"); }; output_list.drawHeaderCallback = rect => { EditorGUI.LabelField(rect, "Output Parameters"); }; variable_list.onReorderCallback = list => { GraphEditor.current_validate = true; }; input_list.onReorderCallback = list => { GraphEditor.current_validate = true; }; output_list.onReorderCallback = list => { GraphEditor.current_validate = true; }; variable_list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { rect.height = EditorGUIUtility.singleLineHeight; Rect rect_declaring = new Rect(rect.x, rect.y, 10.0f, EditorGUIUtility.singleLineHeight); rect.y += 2; Rect rect_name = new Rect(rect.x + 20.0f, rect.y, rect.width / 2.0f, EditorGUIUtility.singleLineHeight); Rect rect_type = new Rect(rect.x + rect.width / 2.0f + 30.0f, rect.y, rect.width - (rect.width / 2.0f + 30.0f), EditorGUIUtility.singleLineHeight); string new_name = EditorGUI.TextField(rect_name, asset.graph.variableParameters[index].name); bool new_declaring_value = EditorGUI.Toggle(rect_declaring, asset.graph.variableParameters[index].is_public); if (new_name != asset.graph.variableParameters[index].name) { UndoManager.RecordObject(asset, "Variable Name Change"); asset.graph.variableParameters[index].name = new_name; GraphEditor.current_validate = true; } if (new_declaring_value != asset.graph.variableParameters[index].is_public) { UndoManager.RecordObject(asset, "Variable Declaring Type Change"); asset.graph.variableParameters[index].is_public = new_declaring_value; GraphEditor.current_validate = true; } GUI.Label(rect_type, asset.graph.variableParameters[index].valueType.GetTypeName()); }; input_list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { rect.height = EditorGUIUtility.singleLineHeight; Rect rect_declaring = new Rect(rect.x, rect.y, 10.0f, EditorGUIUtility.singleLineHeight); rect.y += 2; Rect rect_name = new Rect(rect.x + 20.0f, rect.y, rect.width / 2.0f, EditorGUIUtility.singleLineHeight); Rect rect_type = new Rect(rect.x + rect.width / 2.0f + 30.0f, rect.y, rect.width - (rect.width / 2.0f + 30.0f), EditorGUIUtility.singleLineHeight); string new_name = EditorGUI.TextField(rect_name, asset.graph.inputParameters[index].name); bool new_declaring_value = EditorGUI.Toggle(rect_declaring, asset.graph.inputParameters[index].is_public); if (new_name != asset.graph.inputParameters[index].name) { UndoManager.RecordObject(asset, "Input Parameter Name Change"); asset.graph.inputParameters[index].name = new_name; GraphEditor.current_validate = true; } if (new_declaring_value != asset.graph.inputParameters[index].is_public) { UndoManager.RecordObject(asset, "Input Parameter Declaring Type Change"); asset.graph.inputParameters[index].is_public = new_declaring_value; GraphEditor.current_validate = true; } GUI.Label(rect_type, asset.graph.inputParameters[index].valueType.GetTypeName()); }; output_list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { rect.height = EditorGUIUtility.singleLineHeight; Rect rect_declaring = new Rect(rect.x, rect.y, 10.0f, EditorGUIUtility.singleLineHeight); rect.y += 2; Rect rect_name = new Rect(rect.x + 20.0f, rect.y, rect.width / 2.0f, EditorGUIUtility.singleLineHeight); Rect rect_type = new Rect(rect.x + rect.width / 2.0f + 30.0f, rect.y, rect.width - (rect.width / 2.0f + 30.0f), EditorGUIUtility.singleLineHeight); string new_name = EditorGUI.TextField(rect_name, asset.graph.outputParameters[index].name); bool new_declaring_value = EditorGUI.Toggle(rect_declaring, asset.graph.outputParameters[index].is_public); if (new_name != asset.graph.outputParameters[index].name) { UndoManager.RecordObject(asset, "Output Parameter Name Change"); asset.graph.outputParameters[index].name = new_name; GraphEditor.current_validate = true; } if (new_declaring_value != asset.graph.outputParameters[index].is_public) { UndoManager.RecordObject(asset, "Output Parameter Declaring Type Change"); asset.graph.outputParameters[index].is_public = new_declaring_value; GraphEditor.current_validate = true; } GUI.Label(rect_type, asset.graph.outputParameters[index].valueType.GetTypeName()); }; variable_list.onRemoveCallback = (ReorderableList list) => { UndoManager.RecordObject(target, "Remove parameter"); asset.graph.RemoveParameterAt(list.index, ParameterType.Variable); list.index = list.count - 1; GraphEditor.current_validate = true; }; input_list.onRemoveCallback = (ReorderableList list) => { UndoManager.RecordObject(target, "Remove parameter"); asset.graph.RemoveParameterAt(list.index, ParameterType.Input); list.index = list.count - 1; GraphEditor.current_validate = true; }; output_list.onRemoveCallback = (ReorderableList list) => { UndoManager.RecordObject(target, "Remove parameter"); asset.graph.RemoveParameterAt(list.index, ParameterType.Output); list.index = list.count - 1; GraphEditor.current_validate = true; }; variable_list.onAddDropdownCallback = (Rect buttonRect, ReorderableList list) => { ShowMenu(asset, ParameterType.Variable); }; input_list.onAddDropdownCallback = (Rect buttonRect, ReorderableList list) => { ShowMenu(asset, ParameterType.Input); }; output_list.onAddDropdownCallback = (Rect buttonRect, ReorderableList list) => { ShowMenu(asset, ParameterType.Output); }; }