public void DisplayNodeInfo(Node node) { if (node != null) { GUILayout.BeginHorizontal(); if (GUILayout.Button(node.GameObject.name, "Button")) { obj.ToggleSelect(node.GameObject); } /*if (GUILayout.Button (node.Selected ? "*" : " ", "Button",GUILayout.Width(20))) { * obj.ToggleSelect(node.GameObject); * }*/ GUILayout.EndHorizontal(); foreach (var child in node.Childs) { GUILayout.BeginHorizontal(); GUILayout.Space(20); DisplayNodeInfo(child); GUILayout.EndHorizontal(); } } }
/// <summary> /// displaying each node info /// </summary> public void DisplayNodeInfo(Node node) { if (node != null) { // node name and go, lock button, reset button, add task button GUILayout.BeginHorizontal(); GUILayout.Space(indentLevel * 10); if (GUILayout.Button(node.Name + " (" + (node.GameObject == null?"Missing!": node.GameObject.name) + ")" + (node.Selected?"*":""), "Button")) { EditorGUIUtility.PingObject(node.GameObject); obj.ToggleSelect(node); } // to lock or unlock node for interaction if (GUILayout.Button((node.Locked ? "X" : " "), "Button", GUILayout.Width(20))) { if (node.Locked) { node.Locked = false; } else { obj.Release(); obj.Deselect(node); node.Locked = true; } } // to reset this specific node if (GUILayout.Button("R", "Button", GUILayout.Width(20))) { obj.Reset(node); } // to add a task related to the game object of this node if (GUILayout.Button("Add Task", "Button", GUILayout.Width(100))) { GenericMenu genericMenu = new GenericMenu(); for (int i = 0; i < MultiPartsObjectEditorUtility.TaskTypes().Length; i++) { genericMenu.AddItem(new GUIContent(MultiPartsObjectEditorUtility.TaskTypes()[i]), false, (param) => { int index = (int)param; switch (index) { case 0: { TaskList tl = obj.TaskList; tl.Tasks.Add(new MovingTask(tl, node.GameObject, obj.transform.InverseTransformPoint(node.GameObject.transform.position), Quaternion.Inverse(obj.transform.rotation) * node.GameObject.transform.rotation)); } break; case 1: { TaskList tl = obj.TaskList; tl.Tasks.Add(new ClickingTask(tl, node.GameObject)); } break; } } , i); } genericMenu.ShowAsContext(); } GUILayout.EndHorizontal(); // node details if (node.Selected) { GUILayout.BeginHorizontal(); GUILayout.Space(indentLevel * 10); GUILayout.BeginVertical(EditorStyles.helpBox); // allows to change the name of the node GUILayout.BeginHorizontal(); GUILayout.Label("Name", GUILayout.Width(100)); node.Name = GUILayout.TextField(node.Name); GUILayout.EndHorizontal(); // allows to change the name of the node GUILayout.BeginHorizontal(); GUILayout.Label("Description", GUILayout.Width(100)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorStyles.textField.wordWrap = true; node.Description = EditorGUILayout.TextArea(node.Description, GUILayout.Height(100)); GUILayout.EndHorizontal(); // allows to change the game object of the node GUILayout.BeginHorizontal(); GUILayout.Label("GO", GUILayout.Width(100)); node.GameObject = (GameObject)EditorGUILayout.ObjectField(node.GameObject, typeof(GameObject), true); GUILayout.EndHorizontal(); // go name GUILayout.BeginHorizontal(); GUILayout.Label("GOName", GUILayout.Width(100)); node.GOName = GUILayout.TextField(node.GOName); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } // node childs if (node.Childs.Count > 0) { indentLevel++; GUILayout.BeginVertical(); foreach (var child in node.Childs) { //GUILayout.BeginHorizontal(); //GUILayout.Space(20); DisplayNodeInfo(child); //GUILayout.EndHorizontal(); } GUILayout.EndVertical(); indentLevel--; } } }