상속: ISerializable
예제 #1
0
 public NodeInput(Node n)
 {
     nodeID = n.UID; constValue = float.NaN;
 }
예제 #2
0
        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();
        }
예제 #3
0
        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));
        }
예제 #4
0
        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;
        }