示例#1
0
    public void LoadNodeCanvas(string path)
    {
        nodeGroupCanvas = NodeEditorSaveManager.LoadNodeCanvas(path);
        if (nodeGroupCanvas != null)
        {
            List <NodeEditorState> editorStates = NodeEditorSaveManager.LoadEditorStates(path);
            editorState              = editorStates.Count == 0? CreateInstance <NodeEditorState> () : editorStates[0];
            editorState.canvas       = nodeGroupCanvas;
            editorState.parentEditor = NodeEditor.curEditorState;
            editorState.drawing      = edit;
            editorState.name         = "GroupNode_EditorState";

            string[] folders    = path.Split(new char[] { '/' }, StringSplitOptions.None);
            string   canvasName = folders [folders.Length - 1];
            if (canvasName.EndsWith(".asset"))
            {
                canvasName = canvasName.Remove(canvasName.Length - 6);
            }
            name = canvasName;
        }
        else
        {
            name = "Node Group";
        }
    }
示例#2
0
    public void LoadNodeCanvas(string path)
    {
        // Else it will be stuck forever
        NodeEditor.StopTransitioning(canvas);

        // Load the NodeCanvas
        canvas = NodeEditorSaveManager.LoadNodeCanvas(path);
        if (canvas == null)
        {
            NewNodeCanvas();
            return;
        }

        // Load the associated MainEditorState
        List <NodeEditorState> editorStates = NodeEditorSaveManager.LoadEditorStates(path);

        if (editorStates.Count == 0)
        {
            state = ScriptableObject.CreateInstance <NodeEditorState> ();
        }
        else
        {
            state = editorStates.Find(x => x.name == "MainEditorState");
            if (state == null)
            {
                state = editorStates[0];
            }
        }
        state.canvas = canvas;

        NodeEditor.RecalculateAll(canvas);
    }
示例#3
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();
                }
            }
        }
示例#4
0
        /// <summary>
        /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path
        /// </summary>
        public void LoadNodeCanvas(string path)
        {
            // Else it will be stuck forever
            NodeEditor.StopTransitioning(mainNodeCanvas);

            // 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();
        }