コード例 #1
0
        /// <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, nodeCanvas, cacheWorkingCopy, true);
            }

            CheckCurrentCache();
                        #endif
        }
コード例 #2
0
        /// <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
        }
コード例 #3
0
 /// <summary>
 /// Saves the mainNodeCanvas and it's associated mainEditorState as an asset at path
 /// </summary>
 public void SaveSceneNodeCanvas(string path)
 {
     nodeCanvas.editorStates = new NodeEditorState[] { editorState };
     NodeEditorSaveManager.SaveSceneNodeCanvas(path, ref nodeCanvas, true);
     editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier);
     if (useCache)
     {
         DeleteCache();
     }
     NodeEditor.RepaintClients();
 }
コード例 #4
0
        /// <summary>
        /// Saves the mainNodeCanvas and it's associated mainEditorState as an asset at path
        /// </summary>
        public void SaveSceneNodeCanvas(string path)
        {
            nodeCanvas.editorStates = new NodeEditorState[] { editorState };
            bool switchedToScene = !nodeCanvas.livesInScene;

            NodeEditorSaveManager.SaveSceneNodeCanvas(path, ref nodeCanvas, true);
            editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier);
            if (switchedToScene)
            {
                RecreateCache();
            }
            NodeEditor.RepaintClients();
        }
コード例 #5
0
        /// <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
        }