public void OpenGraph(BehaviourGraph openGraph) { targetGraph = openGraph; dragging_Position = Vector2.zero; Repaint(); }
private void DrawTopBar() { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true)); if (GUILayout.Button("Load Graph", EditorStyles.toolbarButton, GUILayout.Width(100))) { controlID = EditorGUIUtility.GetControlID(FocusType.Passive); EditorGUIUtility.ShowObjectPicker <BehaviourGraph> (targetGraph, false, "", controlID); } string commandName = currentEvent.commandName; if (commandName == "ObjectSelectorUpdated") { Repaint(); } else if (commandName == "ObjectSelectorClosed") { if (EditorGUIUtility.GetObjectPickerControlID() == controlID) { BehaviourGraph nextGraph = EditorGUIUtility.GetObjectPickerObject() as BehaviourGraph; if (nextGraph == null) { // CloseGraph (); } else { if (targetGraph != nextGraph) { OpenGraph(nextGraph.GetInstanceID(), 0); } } return; } } GUILayout.Space(5.0f); EditorGUI.BeginDisabledGroup(targetGraph == null); if (GUILayout.Button("Goto Asset", EditorStyles.toolbarButton, GUILayout.Width(100))) { EditorUtility.FocusProjectWindow(); EditorGUIUtility.PingObject(targetGraph); } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); }
private void HandleDragAndDrop(Rect dropArea) { if (dropArea.Contains(Event.current.mousePosition)) { if (!IsValidImport(DragAndDrop.objectReferences)) { DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; return; } DragAndDrop.visualMode = DragAndDropVisualMode.Generic; if (Event.current.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); for (int i = 0; i < DragAndDrop.objectReferences.Length; i++) { object importObject = DragAndDrop.objectReferences[i]; if (importObject.GetType() == typeof(MonoScript)) { MonoScript monoScriptImport = (MonoScript)importObject; Type monoScriptType = monoScriptImport.GetClass(); if (monoScriptType != null && typeof(BehaviourNode).IsAssignableFrom(monoScriptType)) { AddNodeCallback(monoScriptType, Event.current.mousePosition); } } else if (typeof(BehaviourGraph).IsAssignableFrom(importObject.GetType())) { BehaviourGraph graphImport = (BehaviourGraph)importObject; OpenGraph(graphImport); } } } } }
public void CloseGraph() { targetGraph = null; }