mirror of
https://github.com/maxartz15/UnitySerializedReferenceUI.git
synced 2024-11-22 07:35:36 +01:00
29 lines
1.0 KiB
C#
29 lines
1.0 KiB
C#
#if UNITY_EDITOR
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace Textus.SerializeReferenceUI.Editor
|
|
{
|
|
[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);
|
|
|
|
IEnumerable<Func<Type, bool>> typeRestrictions = SerializedReferenceUIDefaultTypeRestrictions.GetAllBuiltInTypeRestrictions(fieldInfo);
|
|
property.ShowContextMenuForManagedReferenceOnMouseMiddleButton(position, typeRestrictions);
|
|
|
|
EditorGUI.PropertyField(position, property, true);
|
|
EditorGUI.EndProperty();
|
|
}
|
|
}
|
|
}
|
|
#endif |