using UnityEngine;
using UnityEngine.Splines;
namespace UnityEditor.Splines
{
///
/// Create a property drawer for types.
///
[CustomPropertyDrawer(typeof(SplineInfo))]
public class SplineInfoPropertyDrawer : PropertyDrawer
{
///
/// Returns the height of a SerializedProperty in pixels.
///
/// The SerializedProperty to calculate height for.
/// The label of the SerializedProperty.
/// Returns the height of a SerializedProperty in pixels.
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorStyles.popup.CalcSize(label).y * 2;
}
///
/// Creates an interface for a SerializedProperty with an integer property type.
///
/// Rectangle on the screen to use for the property GUI.
/// The SerializedProperty to make the custom GUI for.
/// The label of this property.
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var obj = property.FindPropertyRelative("m_Object");
var con = property.FindPropertyRelative("m_Container");
var ind = property.FindPropertyRelative("m_SplineIndex");
if (con.managedReferenceValue != null && obj.objectReferenceValue == null)
EditorGUI.LabelField(SplineGUIUtility.ReserveSpaceForLine(ref position), "ISplineContainer",
property.managedReferenceFieldTypename);
else
{
EditorGUI.ObjectField(SplineGUIUtility.ReserveSpaceForLine(ref position), obj, typeof(ISplineContainer),
new GUIContent("Spline Container"));
}
EditorGUI.PropertyField(SplineGUIUtility.ReserveSpaceForLine(ref position), ind);
}
}
}