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(); }
/// <summary> /// Converts the type of the canvas to the specified type. /// </summary> public static NodeCanvas ConvertCanvasType(NodeCanvas canvas, Type newType) { NodeCanvas convertedCanvas = canvas; if (canvas.GetType() != newType && newType != typeof(NodeCanvas) && newType.IsSubclassOf(typeof(NodeCanvas))) { canvas = NodeEditorSaveManager.CreateWorkingCopy(canvas, true); convertedCanvas = NodeCanvas.CreateCanvas(newType); convertedCanvas.nodes = canvas.nodes; convertedCanvas.editorStates = canvas.editorStates; convertedCanvas.Validate(); } return(convertedCanvas); }
/// <summary> /// Converts the given canvas to the specified type /// </summary> public static NodeCanvas ConvertCanvasType(NodeCanvas canvas, Type newType) { NodeCanvas convertedCanvas = canvas; if (canvas.GetType() != newType && newType.IsSubclassOf(typeof(NodeCanvas))) { canvas.Validate(); canvas = NodeEditorSaveManager.CreateWorkingCopy(canvas); convertedCanvas = NodeCanvas.CreateCanvas(newType); convertedCanvas.nodes = canvas.nodes; convertedCanvas.groups = canvas.groups; convertedCanvas.editorStates = canvas.editorStates; for (int i = 0; i < convertedCanvas.nodes.Count; i++) { if (!CheckCanvasCompability(convertedCanvas.nodes[i].GetID, newType)) { // Check if nodes is even compatible with the canvas, if not delete it convertedCanvas.nodes[i].Delete(); i--; } } convertedCanvas.Validate(); } return(convertedCanvas); }