private void LoadCache() { string lastSessionName = EditorPrefs.GetString("NodeEditorLastSession"); string path = tempSessionPath + "/LastSession.asset"; mainNodeCanvas = NodeEditorSaveManager.LoadNodeCanvas(path, false); if (mainNodeCanvas == null) { NewNodeCanvas(); } else { mainNodeCanvas.name = lastSessionName; List <NodeEditorState> editorStates = NodeEditorSaveManager.LoadEditorStates(path, false); if (editorStates == null || editorStates.Count == 0 || (mainEditorState = editorStates.Find(x => x.name == "MainEditorState")) == null) { // New NodeEditorState mainEditorState = CreateInstance <NodeEditorState> (); mainEditorState.canvas = mainNodeCanvas; mainEditorState.name = "MainEditorState"; NodeEditorSaveManager.AddSubAsset(mainEditorState, path); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } } }
/// <summary> /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path /// </summary> public void LoadNodeCanvas(string path) { // Load the NodeCanvas mainNodeCanvas = NodeEditorSaveManager.LoadNodeCanvas(path, true); if (mainNodeCanvas == null) { Debug.Log("Error loading NodeCanvas from '" + path + "'!"); NewNodeCanvas(); return; } // Load the associated MainEditorState List <NodeEditorState> editorStates = NodeEditorSaveManager.LoadEditorStates(path, true); if (editorStates.Count == 0) { mainEditorState = ScriptableObject.CreateInstance <NodeEditorState> (); Debug.LogError("The save file '" + path + "' did not contain an associated NodeEditorState!"); } else { mainEditorState = editorStates.Find(x => x.name == "MainEditorState"); if (mainEditorState == null) { mainEditorState = editorStates[0]; } } mainEditorState.canvas = mainNodeCanvas; openedCanvasPath = path; NodeEditor.RecalculateAll(mainNodeCanvas); SaveCache(); Repaint(); }
/// <summary> /// Loads the canvas from the cache save file /// Called whenever a reload was made /// </summary> private void LoadCache() { #if UNITY_EDITOR if (!useCache) { NewNodeCanvas(); return; } // Try to load the NodeCanvas if ( (!File.Exists(lastSessionPath) || (nodeCanvas = NodeEditorSaveManager.LoadNodeCanvas(lastSessionPath, cacheWorkingCopy)) == null) && // Check for asset cache (nodeCanvas = NodeEditorSaveManager.LoadSceneNodeCanvas("lastSession", cacheWorkingCopy)) == null) // Check for scene cache { NewNodeCanvas(); return; } // Fetch the associated MainEditorState editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier); #if EDITOR_CACHE_ASSET if (!nodeCanvas.livesInScene && !UnityEditor.AssetDatabase.Contains(editorState)) { NodeEditorSaveManager.AddSubAsset(editorState, lastSessionPath); } #endif CheckCurrentCache(); UpdateCanvasInfo(); nodeCanvas.TraverseAll(); NodeEditor.RepaintClients(); #endif }
/// <summary> /// Loads the canvas from the cache save file /// Called whenever a reload was made /// </summary> private void LoadCache() { if (!useCache) { NewNodeCanvas(); return; } // Try to load the NodeCanvas if (!File.Exists(lastSessionPath) || (nodeCanvas = NodeEditorSaveManager.LoadNodeCanvas(lastSessionPath, false)) == null) //if(true) { NewNodeCanvas(); return; } // Fetch the associated MainEditorState editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier); if (!UnityEditor.AssetDatabase.Contains(editorState)) { NodeEditorSaveManager.AddSubAsset(editorState, lastSessionPath); } CheckCurrentCache(); NodeEditor.RecalculateAll(nodeCanvas); NodeEditor.RepaintClients(); }
/// <summary> /// Loads the canvas from the cache save file /// Called whenever a reload was made /// </summary> public void LoadCache() { #if CACHE if (!useCache) { // Simply create a ne canvas NewNodeCanvas(); return; } // Try to load the NodeCanvas if ((!File.Exists(lastSessionPath) || (nodeCanvas = NodeEditorSaveManager.LoadNodeCanvas(lastSessionPath, cacheWorkingCopy)) == null) && // Check for asset cache (nodeCanvas = NodeEditorSaveManager.LoadSceneNodeCanvas("lastSession", cacheWorkingCopy)) == null) // Check for scene cache { NewNodeCanvas(); return; } // Fetch the associated MainEditorState editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier); UpdateCanvasInfo(); nodeCanvas.Validate(); nodeCanvas.TraverseAll(); NodeEditor.RepaintClients(); #endif }
/// <summary> /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path /// </summary> public void LoadNodeCanvas(string path) { // Try to load the NodeCanvas if (!File.Exists(path) || (nodeCanvas = NodeEditorSaveManager.LoadNodeCanvas(path, true)) == null) { NewNodeCanvas(); return; } editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier); openedCanvasPath = path; RecreateCache(); UpdateCanvasInfo(); nodeCanvas.TraverseAll(); NodeEditor.RepaintClients(); }
/// <summary> /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path /// </summary> public void LoadNodeCanvas(string path) { // Try to load the NodeCanvas if (!File.Exists(path) || (nodeCanvas = NodeEditorSaveManager.LoadNodeCanvas(path, true)) == null) { NewNodeCanvas(); return; } editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier); openedCanvasPath = path; if (useCache) { SaveCache(); } NodeEditor.RecalculateAll(nodeCanvas); NodeEditor.RepaintClients(); }
/// <summary> /// Loads the canvas from the cache save file /// Called whenever a reload was made /// </summary> public void LoadCache() { #if CACHE if (!useCache) { // Simply create a ne canvas NewNodeCanvas(); return; } bool skipLoad = false; if (cacheMemorySODump) { // Check if a memory dump has been found, if so, load that nodeCanvas = ResourceManager.LoadResource <NodeCanvas>(SOMemoryDumpPath); if (nodeCanvas != null && !nodeCanvas.Validate(false)) { Debug.LogWarning("Cache Dump corrupted! Loading crash-proof lastSession, you might have lost a bit of work. \n " + "To prevent this from happening in the future, allow the Node Editor to properly save the cache " + "by clicking out of the window before switching scenes, since there are no callbacks to facilitate this!"); nodeCanvas = null; UnityEditor.AssetDatabase.DeleteAsset(SOMemoryDumpPath); } if (nodeCanvas != null) { skipLoad = true; } } // Try to load the NodeCanvas if (!skipLoad && (!File.Exists(lastSessionPath) || (nodeCanvas = NodeEditorSaveManager.LoadNodeCanvas(lastSessionPath, cacheWorkingCopy)) == null) && // Check for asset cache (nodeCanvas = NodeEditorSaveManager.LoadSceneNodeCanvas("lastSession", cacheWorkingCopy)) == null) // Check for scene cache { NewNodeCanvas(); return; } // Fetch the associated MainEditorState editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier); UpdateCanvasInfo(); nodeCanvas.Validate(); nodeCanvas.TraverseAll(); NodeEditor.RepaintClients(); #endif }
/// <summary> /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path /// </summary> public void LoadNodeCanvas(string path) { // Try to load the NodeCanvas if (!File.Exists(path) || (nodeCanvas = NodeEditorSaveManager.LoadNodeCanvas(path, true)) == null) { NewNodeCanvas(); return; } editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier); openedCanvasPath = path; nodeCanvas.Validate(); RecreateCache(); UpdateCanvasInfo(); nodeCanvas.TraverseAll(); NodeEditor.RepaintClients(); #if UNITY_EDITOR UnityEditor.AssetDatabase.DeleteAsset(SOMemoryDumpPath); NodeEditorUndoActions.CompleteSOMemoryDump(nodeCanvas); #endif }
/// <summary> /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path /// 加载一个Canvas /// </summary> public void LoadNodeCanvas(string path) { //如果路径一致,说明是同一个canvas if (NodeEditor.curEditorState != null && NodeEditor.curEditorState.canvas != null && (NodeEditor.curEditorState.canvas.savePath == path || path.Contains(NodeEditor.curEditorState.canvas.savePath)) && ( NodeEditorSaveManager.GetLastCanvasPath() == path || path.Contains(NodeEditorSaveManager.GetLastCanvasPath()))) { this.nodeCanvas = NodeEditor.curEditorState.canvas; return; } //如果不存在路径,则新建一个DefaultCanvas if (!File.Exists(path) || (nodeCanvas = NodeEditorSaveManager.LoadNodeCanvas(path)) == null) { NewNodeCanvas(); return; } editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier); nodeCanvas.Validate(); UpdateCanvasInfo(); NodeEditor.RepaintClients(); Debug.Log($"加载{path}成功"); }
/// <summary> /// Loads the canvas from the cache save file /// Called whenever a reload was made /// </summary> public void LoadCache() { #if CACHE if (!useCache) { // Simply create a ne canvas NewNodeCanvas(); return; } bool skipLoad = false; if (cacheMemorySODump) { // Check if a memory dump has been found, if so, load that nodeCanvas = ResourceManager.LoadResource <NodeCanvas>(SOMemoryDumpPath); if (nodeCanvas != null) { skipLoad = true; } } // Try to load the NodeCanvas if (!skipLoad && (!File.Exists(lastSessionPath) || (nodeCanvas = NodeEditorSaveManager.LoadNodeCanvas(lastSessionPath, cacheWorkingCopy)) == null) && // Check for asset cache (nodeCanvas = NodeEditorSaveManager.LoadSceneNodeCanvas("lastSession", cacheWorkingCopy)) == null) // Check for scene cache { NewNodeCanvas(); return; } // Fetch the associated MainEditorState editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier); UpdateCanvasInfo(); nodeCanvas.Validate(); nodeCanvas.TraverseAll(); NodeEditor.RepaintClients(); #endif }