public static void CreateNewGraph(string graphName) { NodeGraph currentGraph = (NodeGraph)ScriptableObject.CreateInstance <NodeGraph>(); if (currentGraph != null) { currentGraph.graphName = graphName; currentGraph.InitGraph(); AssetDatabase.CreateAsset(currentGraph, "Assets/Dialogue System/Resources/Database/" + graphName + ".asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); NodeGraphWindow currentWindow = (NodeGraphWindow)EditorWindow.GetWindow <NodeGraphWindow>(); if (currentWindow != null) { currentWindow.currentGraph = currentGraph; } CreateNode(currentWindow.currentGraph, NodeType.Start, new Vector2(104, 136)); CreateNode(currentWindow.currentGraph, NodeType.End, new Vector2(307, 136)); } else { EditorUtility.DisplayDialog("Graph Message", "No se pudo crear el Grapho", "OK"); } }
public static void LoadGraph() { NodeGraph currentGraph = null; string graphPath = EditorUtility.OpenFilePanel("Load Graph", Application.dataPath + "/Dialogue System/Resources/Database/", ""); if (graphPath != "") { int appPathLen = Application.dataPath.Length; string finalPath = graphPath.Substring(appPathLen - 6); currentGraph = (NodeGraph)AssetDatabase.LoadAssetAtPath(finalPath, typeof(NodeGraph)); if (currentGraph != null) { NodeGraphWindow currentWindow = (NodeGraphWindow)EditorWindow.GetWindow <NodeGraphWindow>(); if (currentWindow != null) { currentWindow.currentGraph = currentGraph; } } else { EditorUtility.DisplayDialog("Graph Message", "No se pudo cargar el Grapho seleccionado", "OK"); } } }
//Metodos Principales public static void InitEditorWindow() { currentWindow = EditorWindow.GetWindow <NodeGraphWindow>(); currentWindow.titleContent = new GUIContent("Flow Chart"); CreateViews(); }
public static void UnloadGraph() { NodeGraphWindow currentWindow = (NodeGraphWindow)EditorWindow.GetWindow <NodeGraphWindow>(); if (currentWindow != null) { currentWindow.currentGraph = null; } }
//Metodos extra static void CreateViews() { if (currentWindow != null) { currentWindow.propertyView = new NodePropertyView(); currentWindow.toolView = new ToolbarView(); currentWindow.graphView = new GraphView(); } else { currentWindow = EditorWindow.GetWindow <NodeGraphWindow>(); } }
public static void InitNodeEditor() { NodeGraphWindow.InitEditorWindow(); }