private void DrawParamField(ref Rect fieldRect, ref int index, SerializedProperty property, bool modified = false)
        {
            fieldRect.y += BoxBackgroundMargin;
            int result = EditorGUI.Popup
                         (
                fieldRect,
                GUIContent.none,
                index + 1,
                ParameterListContent.ToArray(),
                SpaceEditorStyles.ParametrizedField
                         );

            bool changed = (result - 1) != index || modified;

            if (changed && DataProvider.CanEditObject(Target))
            {
                if (result > 0 && result <= Parameters.Count)
                {
                    var parameter = Parameters[result - 1];

                    AsParametrized.SetParameter(property.name, parameter);
                }
                else
                {
                    AsParametrized.ClearParameter(property.name);
                }
            }
        }
Ejemplo n.º 2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (!Initialize(ref position, property, label))
            {
                return;
            }

//            Parameters.FindIndex(p => p.Name.Equals(property.name)
//                                      && p.HoldType.Equals(value.Parameter.HoldType)
//                                      && p.HoldType.Type == type);

            DrawBackground(position, DarkRed); // ? Color.white : DarkRed

            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,
                        0,//index + 1,
                        ParameterListContent.ToArray(),
                        SpaceEditorStyles.ParametrizedField
                                 );

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

                            AsParametrized.SetParameter(property.name, parameter);
                        }
                        else
                        {
                            AsParametrized.ClearParameter(property.name);
                        }
                    }
                }
                if (EditorGUI.EndChangeCheck())
                {
                    EditorUtility.SetDirty(Target);
                }
            }
            EditorGUI.EndProperty();
        }
Ejemplo n.º 3
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();
    }
        private void SetContentForParameters()
        {
            if (ParameterListContent == null)
            {
                ParameterListContent = new List <GUIContent>();
            }

            ParameterListContent.Clear();

            ParameterListContent.Add(new GUIContent($"none ({Typename})"));

            foreach (GenericParameter parameter in Parameters)
            {
                ParameterListContent.Add(new GUIContent(parameter.Name));
            }
        }
    private void SetContentForParameters()
    {
        if (ParameterListContent == null)
        {
            ParameterListContent = new List <GUIContent>();
        }

        ParameterListContent.Clear();

        ParameterListContent.Add(new GUIContent(string.Format("none ({0})", Typename)));

        foreach (Parameter parameter in Parameters)
        {
            ParameterListContent.Add(new GUIContent(parameter.Name));
        }
    }