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);
                }
            }
        }
예제 #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();
        }