//This is the hierarchy shown at top left. Recusrsively show the nested path void ShowBreadCrumbNavigation(Graph root) { if (root == null) { return; } //if something selected the inspector panel shows on top of the breadcrub. If external inspector active it doesnt matter, so draw anyway. if (Graph.currentSelection != null && !NCPrefs.useExternalInspector) { return; } var boundInfo = "Bound"; var prefabType = targetOwner != null?PrefabUtility.GetPrefabType(targetOwner) : PrefabType.None; if (prefabType == PrefabType.Prefab) { boundInfo += " Prefab Asset"; } if (prefabType == PrefabType.PrefabInstance) { boundInfo += " Prefab Instance"; } var assetInfo = EditorUtility.IsPersistent(root)? "Asset Reference" : "Instance"; var graphInfo = string.Format("<color=#ff4d4d>({0})</color>", targetOwner != null && targetOwner.graph == root && targetOwner.graphIsBound? boundInfo : assetInfo); GUI.color = new Color(1f, 1f, 1f, 0.5f); GUILayout.BeginVertical(); if (root.currentChildGraph == null) { if (root.agent == null && root.blackboard == null) { GUILayout.Label(string.Format("<b><size=22>{0} {1}</size></b>", root.name, graphInfo)); } else { var agentInfo = root.agent != null? root.agent.gameObject.name : "No Agent"; var bbInfo = root.blackboard != null? root.blackboard.name : "No Blackboard"; GUILayout.Label(string.Format("<b><size=22>{0} {1}</size></b>\n<size=10>{2} | {3}</size>", root.name, graphInfo, agentInfo, bbInfo)); } } else { GUILayout.BeginHorizontal(); //"button" implemented this way due to e.used. It's a weird matter.. GUILayout.Label("⤴ " + root.name, (GUIStyle)"button"); if (Event.current.type == EventType.MouseUp && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) { root.currentChildGraph = null; DebugCallback.SyncSubTree(root, 0); //new add } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); ShowBreadCrumbNavigation(root.currentChildGraph); } GUILayout.EndVertical(); GUI.color = Color.white; }
//Handles events, Mouse downs, ups etc. void HandleEvents(Event e) { //Node click if (e.type == EventType.MouseDown && Graph.allowClick && e.button != 2) { Undo.RegisterCompleteObjectUndo(graph, "Move Node"); if (!e.control) { Graph.currentSelection = this; } if (e.control) { if (isSelected) { Graph.multiSelection.Remove(this); } else { Graph.multiSelection.Add(this); } } if (e.button == 0) { nodeIsPressed = true; } //Double click if (e.button == 0 && e.clickCount == 2) { if (this is IGraphAssignable && (this as IGraphAssignable).nestedGraph != null) { graph.currentChildGraph = (this as IGraphAssignable).nestedGraph; nodeIsPressed = false; DebugCallback.SyncSubTree(graph, (this as SubTree).ID);//new add } else if (this is ITaskAssignable && (this as ITaskAssignable).task != null) { EditorUtils.OpenScriptOfType((this as ITaskAssignable).task.GetType()); } else { EditorUtils.OpenScriptOfType(this.GetType()); } e.Use(); } OnNodePicked(); } //Mouse up if (e.type == EventType.MouseUp) { nodeIsPressed = false; if (graph.autoSort) { Graph.PostGUI += delegate { SortConnectionsByPositionX(); }; } OnNodeReleased(); } }