mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 01:06:01 +08:00
Removed NodeConnection.cs: Node ports now operate by crossreferencing eachother Changed from separate static classes to partial class Removed UNEC Namespace Added live hover info
40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System;
|
|
|
|
/// <summary> Base class for all node graphs </summary>
|
|
public class NodeGraph {
|
|
|
|
/// <summary> All nodes in the graph. <para/>
|
|
/// See: <see cref="AddNode{T}"/> </summary>
|
|
public List<Node> nodes = new List<Node>();
|
|
|
|
public T AddNode<T>() where T : Node {
|
|
T node = default(T);
|
|
nodes.Add(node);
|
|
return node;
|
|
}
|
|
|
|
public Node AddNode(Type type) {
|
|
Node node = (Node)Activator.CreateInstance(type);
|
|
if (node == null) {
|
|
Debug.LogError("Node could node be instanced");
|
|
return null;
|
|
}
|
|
nodes.Add(node);
|
|
return node;
|
|
}
|
|
|
|
/// <summary> Safely remove a node and all its connections </summary>
|
|
/// <param name="node"></param>
|
|
public void RemoveNode(Node node) {
|
|
node.ClearConnections();
|
|
nodes.Remove(node);
|
|
}
|
|
|
|
public void Clear() {
|
|
nodes.Clear();
|
|
}
|
|
}
|