Exemplo n.º 1
0
        /// <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
        }
Exemplo n.º 2
0
        /// <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
        }
Exemplo n.º 3
0
        public void LoadNodeCanvas(NodeCanvas gamenodecanvas, bool copy = true)
        {
            if (gamenodecanvas == null)
            {
                return;
            }

            if (copy)
            {
                nodeCanvas = NodeEditorSaveManager.CreateWorkingCopy(gamenodecanvas);
            }
            else
            {
                nodeCanvas = gamenodecanvas;
            }

            NodeEditorCallbacks.IssueOnLoadCanvas(nodeCanvas);

            editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier);

            //openedCanvasPath = path;
            nodeCanvas.Validate();
            RecreateCache();
            UpdateCanvasInfo();
            nodeCanvas.TraverseAll();
            NodeEditor.RepaintClients();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path
        /// </summary>
        public void LoadSceneNodeCanvas(string path)
        {
            if (path.StartsWith("SCENE/"))
            {
                path = path.Substring(6);
            }

            // Try to load the NodeCanvas
            if ((nodeCanvas = NodeEditorSaveManager.LoadSceneNodeCanvas(path, true)) == null)
            {
                NewNodeCanvas();
                return;
            }
            editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier);

#if UNITY_EDITOR
            UnityEditor.AssetDatabase.DeleteAsset(SOMemoryDumpPath);
#endif

            openedCanvasPath = path;
            nodeCanvas.Validate();
            RecreateCache();
            UpdateCanvasInfo();
            nodeCanvas.TraverseAll();
            NodeEditor.RepaintClients();
        }
Exemplo n.º 5
0
        public void ConvertCanvasType(Type newType)
        {
            NodeCanvas canvas = NodeCanvasManager.ConvertCanvasType(nodeCanvas, newType);

            if (canvas != nodeCanvas)
            {
                nodeCanvas = canvas;
                RecreateCache();
                UpdateCanvasInfo();
                nodeCanvas.TraverseAll();
                NodeEditor.RepaintClients();
            }
        }
Exemplo n.º 6
0
 public void SetCanvas(NodeCanvas canvas)
 {
     if (nodeCanvas != canvas)
     {
         canvas.Validate(true);
         nodeCanvas  = canvas;
         editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier);
         RecreateCache();
         UpdateCanvasInfo();
         nodeCanvas.TraverseAll();
         NodeEditor.RepaintClients();
     }
 }
Exemplo n.º 7
0
        /// <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 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
        }
Exemplo n.º 9
0
        /// <summary>
        /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path
        /// </summary>
        public void LoadSceneNodeCanvas(string path)
        {
            if (path.StartsWith("SCENE/"))
            {
                path = path.Substring(6);
            }

            // Try to load the NodeCanvas
            if ((nodeCanvas = NodeEditorSaveManager.LoadSceneNodeCanvas(path, true)) == null)
            {
                NewNodeCanvas();
                return;
            }
            editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier);

            openedCanvasPath = path;
            nodeCanvas.Validate();
            RecreateCache();
            UpdateCanvasInfo();
            nodeCanvas.TraverseAll();
            NodeEditor.RepaintClients();
        }
Exemplo n.º 10
0
        /// <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
        }
Exemplo n.º 11
0
        /// <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
        }