public DiagramWindowNode(int index, DiagramNode node, SerializedProperty nodeSP, DiagramWindow window)
 {
     this.index             = index;
     this.node              = node;
     this.nodeSP            = nodeSP;
     this.window            = window;
     propertyNameLabelWidth = 0f;
     nodeNameLabelWidth     = GUI.skin.label.CalcSize(new GUIContent(node.Name)).x;
     nodeRect.width         = nodeNameLabelWidth;
     for (int i = 0, l = node.PropertyCount; i < l; i++)
     {
         float labelWidth = GUI.skin.label.CalcSize(new GUIContent(node.GetPropertyName(i))).x;
         if (labelWidth > nodeRect.width)
         {
             nodeRect.width = labelWidth;
         }
         if (labelWidth > propertyNameLabelWidth)
         {
             propertyNameLabelWidth = labelWidth;
         }
     }
     nodeRect.width += DOUBLE_PADDING;
     if (node.Function == null || node.Function.type != FunctionType.Input)
     {
         nodeRect.height = Mathf.Max(1, node.PropertyCount) * CONNECTOR_OFFSET_Y + 22f;
     }
     else
     {
         nodeRect.height = CONNECTOR_OFFSET_Y + 22f;
     }
     nodeRect.x = node.position.x;
     nodeRect.y = node.position.y;
 }
        public virtual void OnNodeGUI(DiagramWindowEvent e)
        {
            // Draw the window with property labels.
            Rect r = new Rect(1f, 20f, nodeRect.width - DOUBLE_PADDING, 20f);

            GUI.BeginGroup(nodeRect, node.Name, IsFocused ? window.activeNodeStyle : window.normalNodeStyle);

            if (node.Function == null || node.Function.type != FunctionType.Input)
            {
                for (int i = 0, l = node.PropertyCount; i < l; i++)
                {
                    GUI.Label(r, node.GetPropertyName(i));
                    r.y += 16f;
                }
                GUI.EndGroup();

                // Draw the property connectors.
                float
                    xOffset = nodeRect.x - 17f,
                    yOffset = nodeRect.y + 21f;
                r.width = r.height = CONNECTOR_SIZE;
                for (int i = 0, l = node.PropertyCount; i < l; i++)
                {
                    r.x = xOffset;
                    r.y = yOffset;
                    if (e.IsTouchBeginInsideRect(r))
                    {
                        window.StartTransaction(new ConnectionDragTransaction(this, i, new Vector2(r.x, r.center.y) - window.scrollPosition));
                        e.Use();
                    }
                    GUI.Box(r, node.Function == null ? " ?" : typeBoxStrings[(int)node.Function.propertyTypes[i]], window.connectorBoxStyle);
                    int argumentIndex = node.argumentIndices[i];
                    if (argumentIndex >= 0)
                    {
                        DrawConnection(argumentIndex, r);
                    }
                    else
                    {
                        DrawFixedValue(i, r);
                    }
                    yOffset += CONNECTOR_OFFSET_Y;
                }
            }
            else
            {
                GUI.Label(r, node.GetPropertyName(0));
                GUI.EndGroup();
            }

            // Draw the result connector.
            if (node.Function == null)
            {
                GUI.Box(OutputConnectionRect, " ?", window.connectorBoxStyle);
            }
            else if (node.Function.returnType != ValueType.None)
            {
                GUI.Box(OutputConnectionRect, typeBoxStrings[(int)node.Function.returnType], window.connectorBoxStyle);
            }
        }