2020-05-16 15:17:04 +02:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
[CustomPropertyDrawer(typeof(SerializeReferenceMenuAttribute))]
|
|
|
|
|
public class SerializeReferenceMenuAttributeDrawer : PropertyDrawer
|
|
|
|
|
{
|
|
|
|
|
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
|
|
|
|
{
|
|
|
|
|
return EditorGUI.GetPropertyHeight(property, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
|
|
|
|
{
|
|
|
|
|
EditorGUI.BeginProperty(position, label, property);
|
|
|
|
|
|
2020-05-16 19:15:24 +02:00
|
|
|
|
var typeRestrictions = SerializedReferenceUIDefaultTypeRestrictions.GetAllBuiltInTypeRestrictions(fieldInfo);
|
2020-05-16 15:17:04 +02:00
|
|
|
|
property.ShowContextMenuForManagedReferenceOnMouseMiddleButton(position, typeRestrictions);
|
|
|
|
|
|
|
|
|
|
EditorGUI.PropertyField(position, property, true);
|
|
|
|
|
EditorGUI.EndProperty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|