mirror of
https://github.com/maxartz15/UnitySerializedReferenceUI.git
synced 2024-11-26 01:25:30 +01:00
eeaadfc569
Core now formed and contains all useful utility to create custom ui with restrictions. Many methods was extracted from different classes and moved to core. Undo is now supported(because unity's undo bug seems to be fixed). Example now moved into same level separate folder.
27 lines
861 B
C#
27 lines
861 B
C#
#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);
|
|
|
|
var typeRestrictions = SerializedReferenceUIDefaultTypeRestrictions.GetAllBuiltInTypeRestrictions(fieldInfo);
|
|
property.ShowContextMenuForManagedReferenceOnMouseMiddleButton(position, typeRestrictions);
|
|
|
|
EditorGUI.PropertyField(position, property, true);
|
|
EditorGUI.EndProperty();
|
|
}
|
|
}
|
|
#endif
|
|
|