Ejemplo n.º 1
0
        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);
            }
        }