Esempio n. 1
0
 /// <summary>
 /// Creates and loads a new NodeCanvas
 /// </summary>
 public void NewNodeCanvas(Type canvasType = null)
 {
     canvasType = canvasType ?? defaultNodeCanvasType;
     nodeCanvas = NodeCanvas.CreateCanvas(canvasType);
     NewEditorState();
     UpdateCanvasInfo();
     LoadNodeCanvas(nodeCanvas.savePath);
 }
Esempio n. 2
0
 /// <summary>
 /// Creates and loads a new NodeCanvas
 /// </summary>
 public void NewNodeCanvas(Type canvasType = null)
 {
     nodeCanvas = NodeCanvas.CreateCanvas(canvasType);
     //EditorPrefs.SetString ("NodeEditorLastSession", "New Canvas");
     NewEditorState();
     openedCanvasPath = "";
     RecreateCache();
     UpdateCanvasInfo();
 }
Esempio n. 3
0
        /// <summary>
        /// Creates and loads a new NodeCanvas
        /// </summary>
        public void NewNodeCanvas(Type canvasType = null)
        {
            canvasType = canvasType ?? defaultNodeCanvasType;
            nodeCanvas = NodeCanvas.CreateCanvas(canvasType);
            NewEditorState();

            openedCanvasPath = "";
            RecreateCache();
            UpdateCanvasInfo();
        }
        /// <summary>
        /// Creates and loads a new NodeCanvas
        /// </summary>
        public void NewNodeCanvas(Type canvasType = null)
        {
            canvasType = canvasType ?? defaultNodeCanvasType ??             // Pick first canvas in alphabetical order (Calculation usually)
                         NodeCanvasManager.getCanvasDefinitions().OrderBy(c => c.DisplayString).First().CanvasType;
            nodeCanvas = NodeCanvas.CreateCanvas(canvasType);
            NewEditorState();

            openedCanvasPath = "";
            RecreateCache();
            UpdateCanvasInfo();
        }
        /// <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);
        }
Esempio n. 6
0
 /// <summary>
 /// Overwrites canvas with the contents of canvasData, so that all references to canvas will be remained, but both canvases are still seperate.
 /// Only works in the editor!
 /// </summary>
 public static void OverwriteCanvas(ref NodeCanvas targetCanvas, NodeCanvas canvasData)
 {
         #if UNITY_EDITOR
     if (canvasData == null)
     {
         throw new System.ArgumentNullException("Cannot overwrite canvas as data is null!");
     }
     if (targetCanvas == null)
     {
         targetCanvas = NodeCanvas.CreateCanvas(canvasData.GetType());
     }
     UnityEditor.EditorUtility.CopySerialized(canvasData, targetCanvas);
     targetCanvas.name = canvasData.name;
         #else
     throw new System.NotSupportedException("Cannot overwrite canvas in player!");
         #endif
 }
Esempio n. 7
0
        /// <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);
        }