using System.Collections; using System.Collections.Generic; using UnityEngine; using System; /// Base class for all node graphs public abstract class NodeGraph : ScriptableObject { /// All nodes in the graph. /// See: [NonSerialized] public List nodes = new List(); /// Serialized nodes. [SerializeField] public string[] s_nodes; public T AddNode() where T : Node { return AddNode(typeof(T)) as T; } public virtual Node AddNode(Type type) { Node node = (Node)Activator.CreateInstance(type); nodes.Add(node); node.graph = this; return node; } /// Safely remove a node and all its connections /// public void RemoveNode(Node node) { node.ClearConnections(); nodes.Remove(node); } /// Remove all nodes and connections from the graph public void Clear() { nodes.Clear(); } }