/// <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 }