/// <summary> /// Saves the mainNodeCanvas and it's associated mainEditorState as an asset at path /// </summary> public void SaveNodeCanvas(string path) { openedCanvasPath = path; nodeCanvas.editorStates = new NodeEditorState[] { editorState }; NodeEditorSaveManager.SaveNodeCanvas(path, nodeCanvas, true); NodeEditor.RepaintClients(); }
/// <summary> /// Saves the current canvas to the cache /// </summary> public void SaveCache() { #if CACHE if (!useCache) { return; } if (!nodeCanvas || nodeCanvas.GetType() == typeof(NodeCanvas)) { return; } UnityEditor.EditorUtility.SetDirty(nodeCanvas); if (editorState != null) { UnityEditor.EditorUtility.SetDirty(editorState); } lastCacheTime = UnityEditor.EditorApplication.timeSinceStartup; nodeCanvas.editorStates = new NodeEditorState[] { editorState }; if (nodeCanvas.livesInScene || nodeCanvas.allowSceneSaveOnly) { NodeEditorSaveManager.SaveSceneNodeCanvas("lastSession", ref nodeCanvas, cacheWorkingCopy); } else { NodeEditorSaveManager.SaveNodeCanvas(lastSessionPath, ref nodeCanvas, cacheWorkingCopy, true); } #endif }
/// <summary> /// Creates a canvas of the specified canvasType as long as it is a subclass of NodeCanvas /// </summary> public static NodeCanvas CreateCanvas(Type canvasType) { NodeCanvas canvas; if (canvasType != null && canvasType.IsSubclassOf(typeof(NodeCanvas))) { canvas = CreateInstance(canvasType) as NodeCanvas; } else { canvas = CreateInstance <DefaultCanvas>(); } canvas.name = canvas.saveName = "New " + canvas.canvasName; if (canvas is DefaultCanvas) { canvas.savePath = NodeEditor.editorPath + "Resources/Saves/DefaultCanvas.asset"; NodeEditorSaveManager.SaveNodeCanvas(canvas.savePath, ref canvas); } else { string panelPath = NodeEditor.editorPath + "Resources/Saves/"; string panelFileName = "Node Canvas"; string path = UnityEditor.EditorUtility.SaveFilePanelInProject("Save Node Canvas", panelFileName, "asset", "", panelPath); canvas.savePath = path; NodeEditorSaveManager.SaveNodeCanvas(canvas.savePath, ref canvas); } canvas.OnCreate(); return(canvas); }
/// <summary> /// Creates a new cache save file for the currently loaded canvas /// Only called when a new canvas is created or loaded /// </summary> public void SaveCache() { #if UNITY_EDITOR if (!useCache) { return; } if (!nodeCanvas || nodeCanvas.GetType() == typeof(NodeCanvas)) { return; } UnityEditor.EditorUtility.SetDirty(nodeCanvas); if (editorState != null) { UnityEditor.EditorUtility.SetDirty(editorState); } #if !EDITOR_CACHE_ASSET lastCacheTime = UnityEditor.EditorApplication.timeSinceStartup; #endif nodeCanvas.editorStates = new NodeEditorState[] { editorState }; if (nodeCanvas.livesInScene) { NodeEditorSaveManager.SaveSceneNodeCanvas("lastSession", ref nodeCanvas, cacheWorkingCopy); } else { NodeEditorSaveManager.SaveNodeCanvas(lastSessionPath, ref nodeCanvas, cacheWorkingCopy, true); } CheckCurrentCache(); #endif }
private void SaveCache() { string canvasName = mainNodeCanvas.name; EditorPrefs.SetString("NodeEditorLastSession", canvasName); NodeEditorSaveManager.SaveNodeCanvas(tempSessionPath + "/LastSession.asset", false, mainNodeCanvas, mainEditorState); mainNodeCanvas.name = canvasName; AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
/// <summary> /// Saves the mainNodeCanvas and it's associated mainEditorState as an asset at path /// </summary> public void SaveNodeCanvas(string path) { nodeCanvas.editorStates = new NodeEditorState[] { editorState }; bool switchedToFile = nodeCanvas.livesInScene; NodeEditorSaveManager.SaveNodeCanvas(path, nodeCanvas, true); if (switchedToFile) { RecreateCache(); } NodeEditor.RepaintClients(); }
/// <summary> /// Creates a new cache save file for the currently loaded canvas /// Only called when a new canvas is created or loaded /// </summary> private void SaveCache() { if (!useCache) { return; } if (nodeCanvas.livesInScene) { DeleteCache(); return; } nodeCanvas.editorStates = new NodeEditorState[] { editorState }; NodeEditorSaveManager.SaveNodeCanvas(lastSessionPath, nodeCanvas, false); CheckCurrentCache(); }
/// <summary> /// Saves the current canvas to the cache /// </summary> public void SaveCache(bool crashSafe = true) { #if CACHE if (!useCache) { return; } if (!nodeCanvas || nodeCanvas.GetType() == typeof(NodeCanvas)) { return; } UnityEditor.EditorUtility.SetDirty(nodeCanvas); if (editorState != null) { UnityEditor.EditorUtility.SetDirty(editorState); } lastCacheTime = UnityEditor.EditorApplication.timeSinceStartup; nodeCanvas.editorStates = new NodeEditorState[] { editorState }; if (nodeCanvas.livesInScene || nodeCanvas.allowSceneSaveOnly) { NodeEditorSaveManager.SaveSceneNodeCanvas("lastSession", ref nodeCanvas, cacheWorkingCopy); } else if (crashSafe) { NodeEditorSaveManager.SaveNodeCanvas(lastSessionPath, ref nodeCanvas, cacheWorkingCopy, true); } if (cacheMemorySODump) { // Functionality for asset saves only if (nodeCanvas.livesInScene || nodeCanvas.allowSceneSaveOnly) { // Delete for scene save so that next cache load, correct lastSession is used UnityEditor.AssetDatabase.DeleteAsset(SOMemoryDumpPath); } else { // Dump all SOs used in this session (even if deleted) in this file to keep them alive for undo NodeEditorUndoActions.CompleteSOMemoryDump(nodeCanvas); NodeEditorSaveManager.ScriptableObjectReferenceDump(nodeCanvas.SOMemoryDump, SOMemoryDumpPath, false); } } #endif }
private static void SaveCanvas(NodeEditorInputInfo info) { if (info.inputEvent.type == EventType.Layout) { return; } #if UNITY_EDITOR NodeEditorState state = info.editorState; if (!string.IsNullOrEmpty(state.canvas.savePath)) { NodeEditorSaveManager.SaveNodeCanvas(state.canvas.savePath, ref state.canvas, true); EditorWindow.focusedWindow.ShowNotification(new GUIContent("Canvas Saved!")); NodeEditorCallbacks.IssueOnSaveCanvas(state.canvas); } else { EditorWindow.focusedWindow.ShowNotification(new GUIContent("No save location found. Use 'Save As' [Ctrl+Alt+S]")); } #endif info.inputEvent.Use(); }
private static void SaveCanvasAs(NodeEditorInputInfo info) { if (info.inputEvent.type == EventType.Layout) { return; } NodeEditorState state = info.editorState; string panelPath = NodeEditor.editorPath + "Resources/Saves/"; if (state.canvas != null && !string.IsNullOrEmpty(state.canvas.savePath)) { panelPath = state.canvas.savePath; } #if UNITY_EDITOR string path = EditorUtility.SaveFilePanelInProject("Save Node Canvas", "Node Canvas", "asset", "", panelPath); if (!string.IsNullOrEmpty(path)) { NodeEditorSaveManager.SaveNodeCanvas(path, ref state.canvas, true); } #endif info.inputEvent.Use(); }
/// <summary> /// Saves the mainNodeCanvas and it's associated mainEditorState as an asset at path /// </summary> public void SaveNodeCanvas(string path) { NodeEditorSaveManager.SaveNodeCanvas(path, true, mainNodeCanvas, mainEditorState); Repaint(); }
/// <summary> /// Saves the mainNodeCanvas and it's associated mainEditorState as an asset at path /// </summary> public void SaveNodeCanvas(string path) { nodeCanvas.editorStates = new NodeEditorState[] { editorState }; NodeEditorSaveManager.SaveNodeCanvas(path, ref nodeCanvas); }