public NodeInput(Node n) { nodeID = n.UID; constValue = float.NaN; }
public void AddNode(Node n, bool generateNewUID = true) { if (n.Owner != null) { n.Owner.RemoveNode(n); } if (generateNewUID) { n.UID = NextUID; NextUID += 1; } n.Owner = this; if (!nodes.Contains(n)) { nodes.Add(n); uidToNode.Add(n.UID, n); } n.OnAddedToGraph(); }
public void RemoveNode(Node n) { nodes.Remove(n); uidToNode.Remove(n.UID); n.Owner = null; //Remove any connections to the node. if (!Output.IsAConstant && Output.NodeID == n.UID) Output = new NodeInput(0.5f); foreach (Node n2 in nodes) for (int i = 0; i < n2.Inputs.Count; ++i) if (!n2.Inputs[i].IsAConstant && n.UID == n2.Inputs[i].NodeID) n2.Inputs[i] = new NodeInput(n2.GetInputDefaultValue(i)); }
private Rect GUINode(Rect nodeRect, Node node) { Color oldCol = GUI.color; GUI.color = (node == null ? new Color(0.65f, 0.65f, 0.65f) : node.GUIColor); nodeRect = GUILayout.Window((node == null ? -1 : (int)node.UID), nodeRect, GUINodeWindow, (node == null ? "Output" : node.PrettyName), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); GUI.color = oldCol; return nodeRect; }