GetNode() public method

Returns "null" if the given Node uid doesn't exist in this graph.
public GetNode ( int uid ) : Node
uid int
return Node
示例#1
0
 /// <summary>
 /// Returns an expession that evaluates to what this input represents.
 /// </summary>
 public string GetExpression(Graph g)
 {
     if (IsAConstant)
     {
         if (float.IsNaN(ConstantValue))
         {
             return "0.0";
         }
         else
         {
             return ConstantValue.ToCodeString();
         }
     }
     else
     {
         return g.GetNode(nodeID).OutputName;
     }
 }
示例#2
0
 /// <summary>
 /// Returns an expession that evaluates to what this input represents.
 /// </summary>
 public string GetExpression(Graph g)
 {
     if (IsAConstant)
     {
         if (float.IsNaN(ConstantValue))
         {
             return("0.0");
         }
         else
         {
             return(ConstantValue.ToCodeString());
         }
     }
     else
     {
         return(g.GetNode(nodeID).OutputName);
     }
 }
示例#3
0
        /// <summary>
        /// Runs the GUI display window for this node.
        /// Returns what happened.
        /// </summary>
        /// <param name="clickedInput">
        /// If the user clicked an input,
        /// the index of that input will be stored in this variable.
        /// </param>
        /// <param name="isSelected">
        /// If this node's output was previously selected, pass -1.
        /// If an input was selected, pass the index of that input.
        /// Otherwise, pass anything else.
        /// </param>
        public GUIResults OnGUI(ref int clickedInput, int isSelected)
        {
            GUIResults result = GUIResults.Nothing;

            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();

            for (int i = 0; i < Inputs.Count; ++i)
            {
                GUILayout.BeginHorizontal();

                GUILayout.Label(InputNames[i]);

                //Button to select input.
                string buttStr = (isSelected == i ? "x" : "X");
                if (GUILayout.Button(buttStr))
                {
                    result       = GUIResults.ClickInput;
                    clickedInput = i;
                }

                //If this input is a constant, expose a text box to edit it.
                if (Inputs[i].IsAConstant)
                {
                    float newVal = EditorGUILayout.FloatField(Inputs[i].ConstantValue);
                    if (AreFloatsDifferent(newVal, Inputs[i].ConstantValue))
                    {
                        result    = GUIResults.Other;
                        Inputs[i] = new NodeInput(newVal);
                    }
                }
                //Otherwise, expose a button to release the connection.
                else
                {
                    Rect    otherPos = Owner.GetNode(Inputs[i].NodeID).Pos;
                    Vector2 endPos   = new Vector2(otherPos.xMax, otherPos.yMin + OutputHeight) - Pos.min;

                    GUIUtil.DrawLine(new Vector2(0.0f, TitleBarHeight + ((float)i * InputSpacing)),
                                     endPos, 2.0f, Color.white);

                    if (GUILayout.Button("Disconnect"))
                    {
                        Inputs[i] = new NodeInput(InputDefaultVals[i]);

                        result = GUIResults.Other;
                    }
                }

                GUILayout.EndHorizontal();
            }

            if (CustomGUI())
            {
                result = GUIResults.Other;
            }

            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical();

            //Output button.
            if (GUILayout.Button(isSelected == -1 ? "o" : "O"))
            {
                result = GUIResults.ClickOutput;
            }

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            //"Duplicate" button.
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Duplicate"))
            {
                result = GUIResults.Duplicate;
            }

            GUILayout.FlexibleSpace();

            //"Delete" button.
            if (GUILayout.Button("Delete"))
            {
                result = GUIResults.Delete;
            }

            GUILayout.EndHorizontal();

            return(result);
        }