Hello everyone.
I am trying to implement a custom property drawer for a struct that wraps an array.
(Unity 2022.3.6f1)
For example:
public class PropertyTest : MonoBehaviour
{
[Serializable]
public struct Wrapper
{
public int[] value;
}
[CustomPropertyDrawer(typeof(Wrapper))]
public class WrapperPropertyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.PropertyField(position, property.FindPropertyRelative("value"), label);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUI.GetPropertyHeight(property.FindPropertyRelative("value"));
}
}
public Wrapper wrappedArray;
public int[] regularArray;
}
This works, but in the inspector the field has some extra indent that I want to get rid of: