/// <summary> /// Create a new RouteNode. /// </summary> /// <param name="route">Route to own the node.</param> public static RouteNode CreateNewNode(Route route, int index) { var go = new GameObject(); RouteNode prevNode = null; if (route.Nodes.Count > 0) { prevNode = route.Nodes.Last(); } go.transform.position = GenerateNewNodePosition(prevNode); go.transform.SetParent(route.transform); go.transform.SetSiblingIndex(index); go.name = GenerateNewNodeName(route.gameObject.name, route.Nodes.Count); var node = go.AddComponent <RouteNode>(); node.EdgeEvent.Type = route.GetComponentInParent <RouteSet>().DefaultEdgeEventType; route.Nodes.Insert(index, node); UnitySceneUtils.Select(go); SceneView.lastActiveSceneView.FrameSelected(); return(node); }
private static void DrawToolShelf(RouteEvent @event) { var iconAddNode = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_new_node") as Texture; var iconAddEvent = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_new_event") as Texture; var iconParent = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_parent") as Texture; var iconNext = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_next") as Texture; var iconPrev = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_prev") as Texture; Rotorz.Games.Collections.ReorderableListGUI.Title("Tools"); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); // Add node button if (FoxKitUiUtils.ToolButton(iconAddNode, "Add a new node.")) { @event.AddNewNode(); } // Add event button if (FoxKitUiUtils.ToolButton(iconAddEvent, "Add a new node event.")) { @event.AddNewRouteNodeEvent(); } // Select parent button if (FoxKitUiUtils.ToolButton(iconParent, "Select parent.")) { UnitySceneUtils.Select(@event.transform.parent.gameObject); } // Select previous node button if (FoxKitUiUtils.ToolButton(iconPrev, "Select previous node.")) { var node = @event.GetComponent <RouteNode>(); if (node == null) { node = @event.transform.parent.GetComponent <RouteNode>(); } node.SelectPreviousNode(); } // Select next node button if (FoxKitUiUtils.ToolButton(iconNext, "Select next node.")) { var node = @event.GetComponent <RouteNode>(); if (node == null) { node = @event.transform.parent.GetComponent <RouteNode>(); } node.SelectNextNode(); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); }
public static RouteSet CreateRouteSet() { // Create RouteSet GameObject and component. var go = new GameObject(); var routeSet = go.AddComponent <RouteSet>(); go.transform.position = Vector3.zero; go.name = ROUTESET_DEFAULT_NAME; // Select new RouteSet. UnitySceneUtils.Select(go); return(routeSet); }
/// <summary> /// Create a new RouteNodeEvent. /// </summary> /// <param name="parent">GameObject parent to own the event.</param> public static RouteNodeEvent CreateNewNodeEvent(RouteNode parent, RouteNodeEventType type) { var go = new GameObject(); go.transform.position = parent.transform.position; go.transform.SetParent(parent.transform); UnitySceneUtils.Select(go); SceneView.lastActiveSceneView.FrameSelected(); var routeEvent = go.AddComponent <RouteNodeEvent>(); routeEvent.Type = type; go.name = GenerateEventName(EventTypeToString(routeEvent.Type), parent.Events.Count); return(routeEvent); }
/// <summary> /// Select the previous node. /// </summary> public void SelectPreviousNode() { var route = transform.GetComponentInParent <Route>(); var id = route.Nodes.IndexOf(this); GameObject nextNode = null; if (id == 0) { nextNode = route.Nodes.Last().gameObject; } else { nextNode = route.Nodes[id - 1].gameObject; } UnitySceneUtils.Select(nextNode); SceneView.lastActiveSceneView.FrameSelected(); }
private void DrawToolShelf(Route route) { var iconAddNode = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_new_node") as Texture; var iconParent = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_parent") as Texture; Rotorz.Games.Collections.ReorderableListGUI.Title("Tools"); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); // Add node button if (FoxKitUiUtils.ToolButton(iconAddNode, "Add a new node to the end of the route.")) { route.AddNewNode(); } // Select parent button if (FoxKitUiUtils.ToolButton(iconParent, "Select parent RouteSet.")) { UnitySceneUtils.Select(route.transform.parent.gameObject); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); }