Пример #1
0
        /// <summary>
        /// Assures a canvas is loaded, either from the cache or new
        /// </summary>
        public void AssureCanvas()
        {
            if (nodeCanvas == null)
            {
                LoadNodeCanvas(NodeEditorSaveManager.GetLastCanvasPath());
            }

            if (editorState == null)
            {
                NewEditorState();
            }
        }
Пример #2
0
        /// <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}成功");
        }