Health/Assets/UVC4UnityAndroidPlugin/Editor/ComponentRestrictionDrawer.cs

22 lines
567 B
C#
Raw Normal View History

2023-11-22 19:42:29 +00:00
using UnityEngine;
using UnityEditor;
[CustomPropertyDrawer(typeof(ComponentRestrictionAttribute))]
public class ComponentRestrictionDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var restriction = (ComponentRestrictionAttribute)attribute;
if (property.propertyType == SerializedPropertyType.ObjectReference)
{
EditorGUI.ObjectField(position, property, restriction.type);
}
else
{
EditorGUI.PropertyField(position, property);
}
}
} // class ComponentRestrictionDrawer