PropertyDrawer - Compact for Vector2/Vector3.

Hi,

Trying to make a property Drawer to work. It does it right, but can’t make space in the inspector.
Here is the code:

CompactAttribute.cs

using UnityEngine;

/// <summary>
/// Prepares variables to be used by PopupDrawer.
/// </summary>

// This is not an editor script. The property attribute class should be placed in a regular script file.
public class CompactAttribute : PropertyAttribute {
    
    public CompactAttribute () {
		return;
    }
}

CompactDrawer.cs

using UnityEditor;
using UnityEngine;
using System;

/// <summary>
/// Creates a compact list with the provided values (Vectors).
/// </summary>

[CustomPropertyDrawer(typeof(CompactAttribute))]
class CompactDrawer : PropertyDrawer {
    // Draw the property inside the given rect
	public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
      	EditorGUIUtility.LookLikeControls ();
		position.xMin += 4;
        position.xMax -= 4;
		//position.yMax += 50;
        // Now draw the property as a Slider or an IntSlider based on whether it's a float or integer.
        if (property.propertyType == SerializedPropertyType.Vector3){
			property.vector3Value = EditorGUI.Vector3Field(position, label.text, property.vector3Value);
		}
        else
		if (property.propertyType == SerializedPropertyType.Vector2){
			property.vector2Value = EditorGUI.Vector2Field(position, label.text, property.vector2Value);
		}
        else
            EditorGUI.LabelField (position, label.text, "Use Compact with Vector3 or Vector2.");
		//EditorGUILayout.Space();
    }
}

Testing the new PropertyDrawer:

Test.js

#pragma strict

@Compact
var Pos : Vector3 = Vector3(0,0,0);

function Update () {
	this.transform.position = Pos;
}

¿Any tip for getting the EditorGUILayout.Space(); in the drawer to work? it do it right, but with one console error.

The proper way to correct the vertical spacing is to override GetPropertyHeight, like so:

public override float GetPropertyHeight (SerializedProperty prop, GUIContent label) 
{
   float extraHeight = 20.0f;  
   return base.GetPropertyHeight(prop, label) + extraHeight;
}

It seems someone found the solution

// Custom List, a Unity C# Editor Tutorial
// unity - How can I create a custom PropertyDrawer for my Point struct? - Game Development Stack Exchange

public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
     return Screen.width < 333 ? (16f + 18f) : 16f;
}