public static void CreateNewGraph(string graphName) { EngineGraph currentGraph = (EngineGraph)ScriptableObject.CreateInstance <EngineGraph>(); if (currentGraph != null) { currentGraph.graphName = graphName; currentGraph.Initialize(); string path = "Assets/Paradox Engine/Graph/Resources/Data/" + graphName + ".asset"; AssetDatabase.CreateAsset(currentGraph, path); EngineGraphCacheUtilities.SaveSessionCache(path); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); EngineGraphWindow currentWindow = (EngineGraphWindow)EditorWindow.GetWindow <EngineGraphWindow>(); if (currentWindow != null) { currentWindow.currentGraph = currentGraph; } CreateNode(currentWindow.currentGraph, EnumNodeType.Start, new Vector2(104, 136)); CreateNode(currentWindow.currentGraph, EnumNodeType.End, new Vector2(307, 136)); } else { EditorUtility.DisplayDialog("Paradox Engine", "Graph creation failed.", "OK"); } }
public static void UnloadGraph() { EngineGraphWindow currentWindow = (EngineGraphWindow)EditorWindow.GetWindow <EngineGraphWindow>(); if (currentWindow != null) { currentWindow.currentGraph = null; } EngineGraphCacheUtilities.ClearSessionCache(); }
public static void DeleteGraph() { EngineGraphWindow currentWindow = (EngineGraphWindow)EditorWindow.GetWindow <EngineGraphWindow>(); foreach (var item in currentWindow.currentGraph.nodes) { GameObject.DestroyImmediate(item, true); } foreach (var param in currentWindow.currentGraph.parameters.Where(x => x.access == Parameters.ParamAccessibility.IsLocal).Where(x => x.graph == currentWindow.currentGraph)) { currentWindow.currentGraph.parameters.UnsuscribeValue(param.Name); } var temp = currentWindow.currentGraph; currentWindow.currentGraph = null; AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(temp)); AssetDatabase.Refresh(); EngineGraphCacheUtilities.ClearSessionCache(); }
public static void LoadSession(string graphPath, bool cache = false) { EngineGraph currentGraph = null; if (graphPath != "") { string finalPath = graphPath; if (!cache) { int appPathLen = Application.dataPath.Length; finalPath = graphPath.Substring(appPathLen - 6); } currentGraph = (EngineGraph)AssetDatabase.LoadAssetAtPath(finalPath, typeof(EngineGraph)); if (currentGraph != null) { EngineGraphWindow currentWindow = (EngineGraphWindow)EditorWindow.GetWindow <EngineGraphWindow>(); if (currentWindow != null) { if (!cache) { EngineGraphCacheUtilities.SaveSessionCache(finalPath); } currentWindow.currentGraph = currentGraph; } } else { EditorUtility.DisplayDialog("Paradox Engine", "Graph load failed.", "OK"); } currentGraph.selectedNode = null; } }