public static void CreateGraph(string _wantedName, string _path) { NodeGraph curGraph = ScriptableObject.CreateInstance <NodeGraph>() as NodeGraph; if (curGraph != null) { curGraph.SetGraphName(_wantedName); curGraph.InitGraph(); if (string.IsNullOrEmpty(_path)) { _path = "Assets/BTNodeEditor/Database"; } AssetDatabase.CreateAsset(curGraph, _path + "/" + curGraph.GetGraphName() + ".asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); NodeEditorWindow curWindow = EditorWindow.GetWindow <NodeEditorWindow>() as NodeEditorWindow; if (curWindow != null) { curWindow.SetCurrentGraph(curGraph); //CreateNode(curGraph, NodeType.ROOT_NODE, curWindow.GetMainView().GetViewRect().center); } else { EditorUtility.DisplayDialog("Error Something Worng", "Wasnt able to the set current graph variable for the NodeEditorWindow", "Ok"); } } else { EditorUtility.DisplayDialog("Error Something Worng", "Wasnt able to create a new graph. See ur friendly programmer", "Ok"); } }