From 49b25e755b70ec412feaaf0b898d6f7e09d2bea6 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 28 Jun 2022 09:40:37 +0800 Subject: +node example --- Other/NodeEditorExamples/Assets/UNEB/NodeGraph.cs | 57 +++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Other/NodeEditorExamples/Assets/UNEB/NodeGraph.cs (limited to 'Other/NodeEditorExamples/Assets/UNEB/NodeGraph.cs') diff --git a/Other/NodeEditorExamples/Assets/UNEB/NodeGraph.cs b/Other/NodeEditorExamples/Assets/UNEB/NodeGraph.cs new file mode 100644 index 00000000..e977e698 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/UNEB/NodeGraph.cs @@ -0,0 +1,57 @@ + +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace UNEB +{ + /// + /// Represents a graph of nodes. + /// + public class NodeGraph : ScriptableObject + { + /// + /// The types of nodes accepted by the graph. + /// + public static HashSet nodeTypes = new HashSet(); + + [HideInInspector] + public List nodes = new List(); + + /// + /// Add a node to the graph. + /// It is recommended that the save manager adds the nodes. + /// + /// + public void Add(Node n) + { + nodes.Add(n); + } + + /// + /// Removes a node from the graph but it is not destroyed. + /// + /// + public void Remove(Node node) + { + nodes.Remove(node); + } + + /// + /// Put the node at the end of the node list. + /// + /// + public void PushToEnd(Node node) + { + if (nodes.Remove(node)) { + nodes.Add(node); + } + } + + /// + /// Gets called right before the graph is saved. + /// Can be used to setup things before saving like sorting nodes. + /// + public virtual void OnSave() { } + } +} \ No newline at end of file -- cgit v1.1-26-g67d0