Exemple #1
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        if (!Initialize(ref position, property, label))
        {
            return;
        }

        int index = AsNode.GetGenericParameterIndex(property.name, fieldInfo.FieldType, Parameters);

        DrawBackground(position, index == -1 ? Color.red : Color.white);

        label = EditorGUI.BeginProperty(position, label, property);
        {
            position.y += BoxBackgroundHeight * 0.5f;
            position    = EditorGUI.PrefixLabel(position, new GUIContent(property.displayName));

            EditorGUI.indentLevel = 0;
            EditorGUI.BeginChangeCheck();
            {
                var objectFieldRect = position;
                objectFieldRect.y += BoxBackgroundMargin;

                int result = EditorGUI.Popup
                             (
                    objectFieldRect,
                    GUIContent.none,
                    index + 1,
                    ParameterListContent.ToArray(),
                    SpaceEditorStyles.ParametrizedField
                             );

                if (!Editor.ExecuteInRuntime())
                {
                    if (result > 0 && result <= Parameters.Count)
                    {
                        var parameter = Parameters[result - 1];

                        AsNode.SetRequiredParameter(property.name, parameter);
                    }
                    else
                    {
                        AsNode.ClearRequiredParamerer(property.name);
                    }
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
            }
        }
        EditorGUI.EndProperty();
    }