Esempio n. 1
0
        /// <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();
        }
Esempio n. 2
0
        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();
                }
            }
        }