Пример #1
0
 public string IDFromInput(InputPin ip)
 {
     if (ip == null)
     {
         return(null);
     }
     return(nodes.IndexOf(ip.parentNode) + ":" + ip.parentNode.InPins.ToList().IndexOf(ip));
 }
Пример #2
0
        public void ConnectPins(InputPin ip, OutputPin op)
        {
            ResetCompiledStatus();

            // limit pin connections per type
            // executions can only have one output, but multiple inputs
            if (op.IsConnected && op.varType == VarType.Exec)
            {
                op.ConnectedInput.ConnectedOutput = null;
            }

            if (ip.IsConnected && ip.varType != VarType.Exec)
            {
                ip.ConnectedOutput.ConnectedInput = null;
            }

            EditorUtility.SetDirty(this);
            ip.ConnectedOutput = op;
            op.ConnectedInput  = ip;
        }
Пример #3
0
 public override void OnAfterGraphDeserialize()
 {
     ConnectedInput = this.parentNode.parentGraph.InputFromID(cInput);
 }
Пример #4
0
        /// <summary>
        /// Draws the pins for the Node;
        /// Each NodeType is drawn with a different color
        /// </summary>
        public void DrawPins()
        {
            GUILayout.BeginArea(body);
            foreach (NodePin pin in AllPins)
            {
                Rect txt = pin.TextBox;
                GUI.Box(pin.bounds, "", skin.GetStyle(pin.StyleName));
                GUI.Label(txt, pin.Name);

                // casting error? wtf, C#
                Vector2 offset = new Vector2(txt.size.x - 15, 0);
                if (!pin.IsConnected && pin is InputPin)
                {
                    InputPin ip = (InputPin)pin;
                    //Debug.Log("Pin: " + pin + "\nVal: " + pin.Value);
                    switch (pin.varType)
                    {
                    case VarType.Bool:     // checkbox
                        ip.SetBool(EditorGUI.Toggle(new Rect(txt.position + offset, new Vector2(15, 15)),
                                                    ip.GetBool()));
                        break;

                    case VarType.Integer:     // int field
                        ip.SetInt(EditorGUI.IntField(new Rect(txt.position + offset, new Vector2(35, 20)),
                                                     ip.GetInt()));
                        break;

                    case VarType.Float:     // float field
                        ip.SetFloat(EditorGUI.FloatField(new Rect(txt.position + offset, new Vector2(45, 20)),
                                                         ip.GetFloat()));
                        break;

                    case VarType.String:     // text field
                        ip.SetString(EditorGUI.TextField(new Rect(txt.position + offset, new Vector2(75, 20)),
                                                         ip.GetString()));
                        break;

                    case VarType.Vector2:     // 2 float fields
                        ip.SetVector2(EditorGUI.Vector2Field(new Rect(txt.position + offset, new Vector2(65, 20)),
                                                             "", ip.GetVector2()));
                        break;

                    case VarType.Vector3:     // 3 float fields
                        ip.SetVector3(EditorGUI.Vector3Field(new Rect(txt.position + offset, new Vector2(85, 20)),
                                                             "", ip.GetVector3()));
                        break;

                    case VarType.Color:     // box showing color
                        ip.SetColor(EditorGUI.ColorField(new Rect(txt.position + offset, new Vector2(65, 20)),
                                                         ip.GetColor()));
                        break;

                    case VarType.Actor:     // text field
                        ip.SetActor((Actor)EditorGUI.ObjectField(new Rect(txt.position + offset, new Vector2(75, 20)),
                                                                 ip.GetActor(), typeof(Actor), true));
                        break;
                    }
                }
            }
            GUILayout.EndArea();
        }