Exemple #1
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        if (SerializedPropertyUtility.IsArrayElement(property))
        {
            if (SerializedPropertyUtility.IndexOfArrayElement(property) == 0)
            {
                //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight), property, true);
                //position.y += EditorGUIUtility.singleLineHeight;

                firstProperty = property;
                SerializedProperty parentProp = SerializedPropertyUtility.GetArrayParentProperty(property);

                if (list == null || list.serializedProperty.propertyPath != parentProp.propertyPath)
                {
                    list = new ReorderableList(parentProp.serializedObject, parentProp, true, true, true, true);

                    list.drawElementCallback   += DrawElement;
                    list.elementHeightCallback += ElementHeightCallback;
                    list.drawHeaderCallback    += DrawHeader;
                    //list.drawFooterCallback += DrawFooter;
                }

                if (list != null)
                {
                    list.elementHeight = maxHeight;
                    //list.DoLayoutList();
                    list.DoList(new Rect(position.x, position.y, position.width, maxHeight));
                }
            }
        }
    }
Exemple #2
0
            public void Add()
            {
                int arraySize = property.arraySize;

                ++property.arraySize;
                SerializedPropertyUtility.ResetValue(property.GetArrayElementAtIndex(arraySize));
            }
        public void ProcessDropInsertion(int insertionIndex)
        {
            if (Event.current.type == EventType.DragPerform)
            {
                var draggedItem = DragAndDrop.GetGenericData(DraggedItem.TypeName) as DraggedItem;

                // Are we just reordering within the same list?
                if (draggedItem.SourceListAdaptor == this)
                {
                    Move(draggedItem.Index, insertionIndex);
                }
                else
                {
                    // Nope, we are moving the item!
                    this.Insert(insertionIndex);
                    SerializedPropertyUtility.CopyPropertyValue(this[insertionIndex], draggedItem.ShoppingItem);
                    if (!Event.current.control)
                    {
                        draggedItem.SourceListAdaptor.Remove(draggedItem.Index);
                    }
                    draggedItem.SourceListAdaptor.arrayProperty.serializedObject.ApplyModifiedProperties();
                    // Ensure that the item remains selected at its new location!
                    s_SelectedList = this;
                }
            }
        }
 /// <summary>
 /// Resets state of the new entry input controls.
 /// </summary>
 public static void ResetActiveNewEntry()
 {
     NewEntryObject.Update();
     SerializedPropertyUtility.ResetValue(NewEntryKeyProperty);
     SerializedPropertyUtility.ResetValue(NewEntryValueProperty);
     NewEntryObject.ApplyModifiedProperties();
 }
Exemple #5
0
        /// <inheritdoc/>
        public void Add()
        {
            int newIndex = _arrayProperty.arraySize;

            ++_arrayProperty.arraySize;
            SerializedPropertyUtility.ResetValue(_arrayProperty.GetArrayElementAtIndex(newIndex));
        }
 public static IEnumerable <MightyEditor> GetMightyEditors()
 {
     foreach (var script in SerializedPropertyUtility.FindAllObjects <MonoBehaviour>())
     {
         if (script.CreateEditor(out var mightyEditor))
         {
             yield return(mightyEditor);
         }
     }
 }
        public static void ApplyAutoValues()
        {
            foreach (var script in SerializedPropertyUtility.FindAllObjects <MonoBehaviour>())
            {
                if (script.CreateEditor(out var mightyEditor))
                {
                    mightyEditor.ApplyAutoValues();
                }
            }

            EditorDrawUtility.MightyDebug("Auto Values Applied");
        }
Exemple #8
0
    // Entry Point
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        if (showDebug)
        {
            Rect sliderRect = new Rect(0, position.y, position.width, normalHeight);
            labelWidthPercent = EditorGUI.Slider(sliderRect, labelWidthPercent, 0, 1);
            sliderRect.y     += debugTool;
            position.yMin    += debugTool;
        }

        float yMax = position.yMax;

        currHeight            = 0;
        EditorGUI.indentLevel = 0;
        isCalcHeight          = false;

        SetupGUIStyle();

        // Inspector Label Width
        labelWidth = position.width * labelWidthPercent;
        EditorGUIUtility.labelWidth = labelWidth;


        currProperty = property.propertyPath;
        SerializedProperty origProp = null;

        // Special case of array element (4.3)
        if (SerializedPropertyUtility.IsArrayElement(property))
        {
            isArrayElement    = true;
            arrayElementIndex = SerializedPropertyUtility.IndexOfArrayElement(property);
            origProp          = SerializedPropertyUtility.GetArrayParentProperty(property);
        }
        else
        {
            origProp = property.Copy();
        }

        AutoPropertyField(position, property, origProp, label, 0, out yMax);

        // delay action
        if (action != null)
        {
            action.Action();
            action = null;
        }

        GUI.skin = null;
    }
Exemple #9
0
        private void MarchList()
        {
            if (string.IsNullOrEmpty(query) && selected == 0)
            {
                return;
            }

            prefabListWorp.ClearArray();

            for (int i = 0; i < prefabListProp.arraySize; i++)
            {
                var prop       = prefabListProp.GetArrayElementAtIndex(i);
                var prefabProp = prop.FindPropertyRelative("prefab");

                if (prefabProp.objectReferenceValue == null || !prefabProp.objectReferenceValue.name.ToLower().Contains(query.ToLower()))
                {
                    continue;
                }

                var containCommandProp = prop.FindPropertyRelative("containsCommand");
                var containsPickupProp = prop.FindPropertyRelative("containsPickup");

                if (selected == 1)
                {
                    if (!containCommandProp.boolValue)
                    {
                        continue;
                    }
                }
                else if (selected == 2)
                {
                    if (!containsPickupProp.boolValue)
                    {
                        continue;
                    }
                }
                else if (selected == 3)
                {
                    if (containCommandProp.boolValue || containsPickupProp.boolValue)
                    {
                        continue;
                    }
                }

                prefabListWorp.InsertArrayElementAtIndex(0);
                SerializedPropertyUtility.CopyPropertyValue(prefabListWorp.GetArrayElementAtIndex(0), prefabListProp.GetArrayElementAtIndex(i));
            }
        }
        /// <inheritdoc/>
        public virtual void Add(SerializedProperty inputKeyProperty, SerializedProperty inputValueProperty)
        {
            if (this.KeysPropertyAdaptor.ArrayProperty.arraySize != this.ValuesPropertyAdaptor.ArrayProperty.arraySize)
            {
                throw new InvalidOperationException("Cannot add entry because of inconsistent count of keys and values.");
            }

            int count = this.KeysPropertyAdaptor.ArrayProperty.arraySize + 1;

            this.KeysPropertyAdaptor.ArrayProperty.arraySize   = count;
            this.ValuesPropertyAdaptor.ArrayProperty.arraySize = count;

            var addedKeyProperty   = this.KeysPropertyAdaptor.ArrayProperty.GetArrayElementAtIndex(count - 1);
            var addedValueProperty = this.ValuesPropertyAdaptor.ArrayProperty.GetArrayElementAtIndex(count - 1);

            SerializedPropertyUtility.CopyPropertyValue(addedKeyProperty, inputKeyProperty);
            SerializedPropertyUtility.CopyPropertyValue(addedValueProperty, inputValueProperty);
        }
Exemple #11
0
    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        float h = 0; // base.GetPropertyHeight(property, label);

        if (SerializedPropertyUtility.IsArrayElement(property))
        {
            if (SerializedPropertyUtility.IndexOfArrayElement(property) == 0)
            {
                h += EditorGUIUtility.singleLineHeight; // header
                h += EditorGUIUtility.singleLineHeight; // footer

                //SerializedProperty parentProp = SerializedPropertyUtility.GetArrayParentProperty(property);
            }
            //h += EditorGUI.GetPropertyHeight(property);
            h += maxHeight;
        }

        return(h);
    }
Exemple #12
0
    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        SerializedProperty origProp = property;
        bool backupFlag             = isArrayElement;

        if (SerializedPropertyUtility.IsArrayElement(property))
        {
            isArrayElement    = true;
            arrayElementIndex = SerializedPropertyUtility.IndexOfArrayElement(property);
            origProp          = SerializedPropertyUtility.GetArrayParentProperty(property);
        }
        else
        {
            origProp = property.Copy();
        }
        float height = GetPropertyHeight(property, origProp, label) + (1) + ((showDebug)? debugTool: 0);

        isArrayElement = backupFlag;
        return(height);
    }
Exemple #13
0
        private void ApplyWorpPrefabList()
        {
            List <SerializedProperty> needAdd = new List <SerializedProperty>();

            if (prefabListWorp.arraySize > 0)
            {
                for (int i = 0; i < prefabListWorp.arraySize; i++)
                {
                    var  newProp         = prefabListWorp.GetArrayElementAtIndex(i);
                    var  newprefabProp   = newProp.FindPropertyRelative("prefab");
                    var  newrematrixProp = newProp.FindPropertyRelative("rematrix");
                    bool contain         = false;
                    for (int j = 0; j < prefabListProp.arraySize; j++)
                    {
                        var prop         = prefabListProp.GetArrayElementAtIndex(j);
                        var prefabProp   = prop.FindPropertyRelative("prefab");
                        var rematrixProp = prop.FindPropertyRelative("rematrix");
                        if (prefabProp.objectReferenceValue == newprefabProp.objectReferenceValue)
                        {
                            if (newrematrixProp.boolValue == rematrixProp.boolValue && rematrixProp.boolValue == false)
                            {
                                SerializedPropertyUtility.CopyPropertyValue(prop, newProp);
                            }
                            contain = true;
                        }
                    }
                    if (!contain)
                    {
                        needAdd.Add(newProp);
                    }
                }
            }

            for (int i = 0; i < needAdd.Count; i++)
            {
                prefabListProp.InsertArrayElementAtIndex(0);
                var newProp = needAdd[i];
                var prop    = prefabListProp.GetArrayElementAtIndex(0);
                SerializedPropertyUtility.CopyPropertyValue(prop, newProp);
            }
        }
    public static object GetParent(this SerializedProperty prop)
    {
        var    path     = prop.propertyPath.Replace(".Array.data[", "[");
        object obj      = prop.serializedObject.targetObject;
        var    elements = path.Split('.');

        foreach (var element in elements.Take(elements.Length - 1))
        {
            if (element.Contains("["))
            {
                var elementName = element.Substring(0, element.IndexOf("["));
                var index       = System.Convert.ToInt32(element.Substring(element.IndexOf("[")).Replace("[", "").Replace("]", ""));
                obj = SerializedPropertyUtility.GetValue(obj, elementName, index);
            }
            else
            {
                obj = SerializedPropertyUtility.GetValue(obj, element);
            }
        }

        return(obj);
    }
Exemple #15
0
    private void MarchList()
    {
        SerializedProperty property       = null;
        SerializedProperty targetProperty = null;

        if (!string.IsNullOrEmpty(query))
        {
            switch ((UILoadType)defultTypeProp.enumValueIndex)
            {
            case UILoadType.LocalPrefab:
                property       = prefabsProp;
                targetProperty = prefabsPropWorp;
                break;

            case UILoadType.LocalBundle:
                property       = bundlesProp;
                targetProperty = bundlesPropWorp;
                break;

            case UILoadType.RemoteBundle:
                property       = rbundlesProp;
                targetProperty = rbundlesPropWorp;
                break;

            default:
                break;
            }
            targetProperty.ClearArray();
            for (int i = 0; i < property.arraySize; i++)
            {
                var assetNameProp = property.GetArrayElementAtIndex(i).FindPropertyRelative("assetName");
                if (assetNameProp.stringValue.ToLower().Contains(query.ToLower()))
                {
                    targetProperty.InsertArrayElementAtIndex(0);
                    SerializedPropertyUtility.CopyPropertyValue(targetProperty.GetArrayElementAtIndex(0), property.GetArrayElementAtIndex(i));
                }
            }
        }
    }
Exemple #16
0
 /// <inheritdoc/>
 public void Insert(int index)
 {
     _arrayProperty.InsertArrayElementAtIndex(index);
     SerializedPropertyUtility.ResetValue(_arrayProperty.GetArrayElementAtIndex(index));
 }
Exemple #17
0
        protected override InitState InitPropertyImpl(SerializedProperty property, BaseAutoValueAttribute baseAttribute)
        {
            var attribute       = (ValueFromAttribute)baseAttribute;
            var attributeTarget = property.GetAttributeTarget <ValueFromAttribute>();
            var propertyTarget  = property.GetPropertyTargetReference();

            if (!attributeTarget.GetType().InfoExist(attribute.ValueName))
            {
                return(new InitState(false, "Callback name: \"" + attribute.ValueName + "\" is invalid"));
            }

            if (!attributeTarget.GetType().GetMemberInfo(attribute.ValueName, new CallbackSignature(property.GetSystemType(), true), out _))
            {
                return(new InitState(false, "\"" + attribute.ValueName + "\" type is invalid"));
            }

            if (!property.isArray || property.propertyType == SerializedPropertyType.String)
            {
                return(SerializedPropertyUtility.SetGenericValue(propertyTarget, property, attribute.ValueName, property.propertyType)
                    ? new InitState(true)
                    : new InitState(false, "\"" + property.displayName + "\" type is not serializable"));
            }

            var state = new InitState(true);
            var index = 0;

            if (property.GetArrayValueFromMember(attributeTarget, attribute.ValueName, out var outArray) &&
                property.CompareArrays(outArray, propertyTarget))
            {
                return(state);
            }

            if (property.arraySize == 0)
            {
                property.InsertArrayElementAtIndex(0);
            }

            if (property.GetArrayElementAtIndex(0).propertyType == SerializedPropertyType.Generic)
            {
                try
                {
                    var propertyType  = property.GetSystemType();
                    var propertyField = propertyTarget.GetField(property.name);
                    var array         = (IList)Array.CreateInstance(propertyType, outArray.Length);

                    for (var i = 0; i < outArray.Length; i++)
                    {
                        array[i] = outArray[i];
                    }

                    propertyField.SetValue(propertyTarget, array);
                    return(new InitState(true));
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                    property.DeleteArrayElementAtIndex(index);
                    return(new InitState(false, "\"" + property.displayName + "\" type is not serializable"));
                }
            }

            property.ClearArray();
            while (index < outArray.Length)
            {
                try
                {
                    property.InsertArrayElementAtIndex(index);
                    if (!(state = SerializedPropertyUtility.SetArrayElementGenericValue(attributeTarget,
                                                                                        property.GetArrayElementAtIndex(index), attribute.ValueName,
                                                                                        property.GetArrayElementAtIndex(index).propertyType, index)
                        ? new InitState(true)
                        : new InitState(false, "\"" + property.displayName + "\" type is not serializable")).isOk)
                    {
                        return(state);
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                    property.DeleteArrayElementAtIndex(index);
                    break;
                }

                index++;
            }

            return(state);
        }
Exemple #18
0
    void CustomPropertyField(Rect position, SerializedProperty prop, GUIContent label, out float yMax)
    {
        Vector2 xRangeContent = new Vector2(GetXRange(prop) + marginWidth.x, position.xMax - GetXRange(prop) - marginWidth.x);

        position.x      = xRangeContent[0];
        position.xMax   = xRangeContent[1];
        position.height = normalHeight;

        Rect controlPos = new Rect(position);

        controlPos.x     += labelWidth;
        controlPos.width -= labelWidth;
        controlPos.height = normalHeight;

        switch (prop.propertyType)
        {
        case SerializedPropertyType.ArraySize:
        {
            if (currProperty != prop.propertyPath)
            {
                position.y += UnknownPropertyField(position, prop, label);
                break;
            }
            if (!isCalcHeight)
            {
                EditorGUI.LabelField(position, label);
                EditorGUI.BeginChangeCheck();

                int intValue = EditorGUI.IntField(controlPos, prop.intValue);

                // Code to execute if GUI.changed
                // was set to true inside the block of code above.
                if (EditorGUI.EndChangeCheck())
                {
                    prop.intValue = intValue;
                }
            }

            position.y += normalHeight;
            break;
        }

        case SerializedPropertyType.Integer:
        {
            if (currProperty != prop.propertyPath)
            {
                position.y += UnknownPropertyField(position, prop, label);
                break;
            }
            if (!isCalcHeight)
            {
                //GUI.Label(position, new GUIContent(label.text), "label");
                controlPos = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(label.text));

                EditorGUI.BeginChangeCheck();

                int intValue = EditorGUI.IntField(controlPos, prop.intValue);

                // Code to execute if GUI.changed
                // was set to true inside the block of code above.
                if (EditorGUI.EndChangeCheck())
                {
                    prop.intValue = intValue;
                }
            }
            position.y += normalHeight;
            break;
        }

        case SerializedPropertyType.Float:
        {
            if (currProperty != prop.propertyPath)
            {
                position.y += UnknownPropertyField(position, prop, label);
                break;
            }
            if (!isCalcHeight)
            {
                controlPos = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(label.text));

                EditorGUI.BeginChangeCheck();

                float floatValue = EditorGUI.FloatField(controlPos, prop.floatValue);

                // Code to execute if GUI.changed
                // was set to true inside the block of code above.
                if (EditorGUI.EndChangeCheck())
                {
                    prop.floatValue = floatValue;
                }
            }
            position.y += normalHeight;
            break;
        }

        case SerializedPropertyType.String:
        {
            if (!isCalcHeight)
            {
                controlPos = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(label.text));

                EditorGUI.BeginChangeCheck();

                string str = EditorGUI.TextField(controlPos, prop.stringValue);

                // Code to execute if GUI.changed
                // was set to true inside the block of code above.
                if (EditorGUI.EndChangeCheck())
                {
                    prop.stringValue = str;
                }
            }
            position.y += normalHeight;
            break;
        }

        case SerializedPropertyType.Color:
        {
            if (!isCalcHeight)
            {
                controlPos = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(label.text));
                EditorGUI.BeginChangeCheck();

                Color color = EditorGUI.ColorField(controlPos, prop.colorValue);

                // Code to execute if GUI.changed
                // was set to true inside the block of code above.
                if (EditorGUI.EndChangeCheck())
                {
                    prop.colorValue = color;
                }
            }
            position.y += normalHeight;
            break;
        }

        case SerializedPropertyType.LayerMask:
        {
            if (!isCalcHeight)
            {
                controlPos = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(label.text));
                EditorGUI.BeginChangeCheck();

                int layer = EditorGUI.LayerField(controlPos, prop.intValue);

                // Code to execute if GUI.changed
                // was set to true inside the block of code above.
                if (EditorGUI.EndChangeCheck())
                {
                    prop.intValue = layer;
                }
            }
            position.y += normalHeight;
            break;
        }

        case SerializedPropertyType.Vector2:
        {
            if (!isCalcHeight)
            {
                EditorGUI.LabelField(position, label);
                EditorGUI.BeginChangeCheck();

                Vector2 vector2Value = EditorGUI.Vector2Field(controlPos, "", prop.vector2Value);

                // Code to execute if GUI.changed
                // was set to true inside the block of code above.
                if (EditorGUI.EndChangeCheck())
                {
                    prop.vector2Value = vector2Value;
                }
            }
            position.y += normalHeight;
            break;
        }

        case SerializedPropertyType.Quaternion:
        {
            if (!isCalcHeight)
            {
                EditorGUI.LabelField(position, label);
                EditorGUI.BeginChangeCheck();

                controlPos.y -= normalHeight;
                Vector4 vector4Value = EditorGUI.Vector4Field(controlPos, "", new Vector4(prop.quaternionValue.x, prop.quaternionValue.y, prop.quaternionValue.z, prop.quaternionValue.w));

                // Code to execute if GUI.changed
                // was set to true inside the block of code above.
                if (EditorGUI.EndChangeCheck())
                {
                    prop.quaternionValue = new Quaternion(vector4Value.x, vector4Value.y, vector4Value.z, vector4Value.w);
                }
            }
            position.y += normalHeight;
            break;
        }

        case SerializedPropertyType.Vector3:
        {
            if (!isCalcHeight)
            {
                EditorGUI.LabelField(position, label);
                EditorGUI.BeginChangeCheck();

                Vector3 vector3Value = EditorGUI.Vector3Field(controlPos, "", prop.vector3Value);

                // Code to execute if GUI.changed
                // was set to true inside the block of code above.
                if (EditorGUI.EndChangeCheck())
                {
                    prop.vector3Value = vector3Value;
                }
            }
            position.y += normalHeight;
            break;
        }

        case SerializedPropertyType.Rect:
        {
            if (!isCalcHeight)
            {
                controlPos = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(label.text));
                EditorGUI.BeginChangeCheck();

                Rect rectValue = EditorGUI.RectField(controlPos, prop.rectValue);

                // Code to execute if GUI.changed
                // was set to true inside the block of code above.
                if (EditorGUI.EndChangeCheck())
                {
                    prop.rectValue = rectValue;
                }
            }
            position.y += doubleHeight;
            break;
        }

        case SerializedPropertyType.Gradient:
        case SerializedPropertyType.Character:
        {
            if (!isCalcHeight)
            {
                // TODO
                EditorGUI.LabelField(position, prop.propertyType.ToString());
                EditorGUI.LabelField(controlPos, "Unsupport type");
            }
            position.y += normalHeight;
            break;
        }

        case SerializedPropertyType.AnimationCurve:
        {
            if (!isCalcHeight)
            {
                controlPos = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(label.text));
                EditorGUI.BeginChangeCheck();

                AnimationCurve animationCurveValue = EditorGUI.CurveField(controlPos, prop.animationCurveValue);

                // Code to execute if GUI.changed
                // was set to true inside the block of code above.
                if (EditorGUI.EndChangeCheck())
                {
                    prop.animationCurveValue = animationCurveValue;
                }
            }
            position.y += normalHeight;
            break;
        }

        case SerializedPropertyType.Bounds:
        {
            if (!isCalcHeight)
            {
                controlPos = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(label.text));
                EditorGUI.BeginChangeCheck();

                Bounds boundsValue = EditorGUI.BoundsField(controlPos, prop.boundsValue);

                // Code to execute if GUI.changed
                // was set to true inside the block of code above.
                if (EditorGUI.EndChangeCheck())
                {
                    prop.boundsValue = boundsValue;
                }
            }
            position.y += doubleHeight;
            break;
        }

        case SerializedPropertyType.Boolean:
        {
            if (!isCalcHeight)
            {
                controlPos = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(label.text));
                EditorGUI.BeginChangeCheck();

                bool boolValue = EditorGUI.Toggle(controlPos, prop.boolValue);

                // Code to execute if GUI.changed
                // was set to true inside the block of code above.
                if (EditorGUI.EndChangeCheck())
                {
                    prop.boolValue = boolValue;
                }
            }
            position.y += normalHeight;
            break;
        }

        case SerializedPropertyType.ObjectReference:
        {
            if (currProperty != prop.propertyPath)
            {
                position.y += UnknownPropertyField(position, prop, label);
                break;
            }
            if (!isCalcHeight)
            {
                Type objType = null;
                SerializedProperty testProp = prop;
                if (SerializedPropertyUtility.IsArrayElement(prop))
                {
                    object obj = SerializedPropertyUtility.GetParent(prop);
                    objType = obj.GetType();
                }

                Type      currType = testProp.serializedObject.targetObject.GetType();
                FieldInfo field    = currType.GetField(testProp.name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                if (field != null)
                {
                    objType = field.FieldType;
                }
                if (objType != null)
                {
                    controlPos = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(label.text));
                    EditorGUI.BeginChangeCheck();
                    UnityEngine.Object objectReferenceValue = EditorGUI.ObjectField(controlPos, prop.objectReferenceValue, objType, true);

                    // Code to execute if GUI.changed
                    // was set to true inside the block of code above.
                    if (EditorGUI.EndChangeCheck())
                    {
                        prop.objectReferenceValue = objectReferenceValue;
                    }
                }
            }
            position.y += normalHeight;
            break;
        }

        case SerializedPropertyType.Enum:
        {
            if (currProperty != prop.propertyPath)
            {
                position.y += UnknownPropertyField(position, prop, label);
                break;
            }
            if (!isCalcHeight)
            {
                Type      currType = prop.serializedObject.targetObject.GetType();
                FieldInfo field    = currType.GetField(prop.name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                if (field != null)
                {
                    Type enumType = field.FieldType;

                    FieldInfo[] fields = enumType.GetFields(BindingFlags.Public | BindingFlags.Static);
                    if (fields != null)
                    {
                        int[] intArray = new int[fields.Length];
                        for (int i = 0; i < fields.Length; i++)
                        {
                            intArray[i] = (int)Convert.ChangeType(fields[i].GetValue(null), typeof(int));
                        }
                        prop.enumValueIndex = (prop.enumValueIndex < 0)? 0: prop.enumValueIndex;
                        EditorGUI.LabelField(position, label);

                        EditorGUI.BeginChangeCheck();
                        int intValue = EditorGUI.IntPopup(controlPos, prop.intValue, prop.enumNames, intArray);

                        // Code to execute if GUI.changed
                        // was set to true inside the block of code above.
                        if (EditorGUI.EndChangeCheck())
                        {
                            prop.intValue = intValue;
                        }
                    }
                }
            }
            position.y += normalHeight;
            break;
        }

        default:
        {
            if (currProperty != prop.propertyPath)
            {
                position.y += UnknownPropertyField(position, prop, label);
                break;
            }
            if (!isCalcHeight)
            {
                Type      currType = prop.serializedObject.targetObject.GetType();
                FieldInfo field    = currType.GetField(prop.name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                if (field != null)
                {
                    EditorGUI.LabelField(position, field.FieldType.ToString());
                }
            }
            position.y += normalHeight;
            break;
        }
        }
        yMax = position.y;
    }