pixelgon/Assets/NaughtyAttributes/Scripts/Editor/NativePropertyDrawers/ShowNativePropertyNativePropertyDrawer.cs
2020-06-05 11:54:36 -07:00

25 lines
1.1 KiB
C#

using System.Reflection;
using UnityEditor;
namespace NaughtyAttributes.Editor
{
[NativePropertyDrawer(typeof(ShowNativePropertyAttribute))]
public class ShowNativePropertyNativePropertyDrawer : NativePropertyDrawer
{
public override void DrawNativeProperty(UnityEngine.Object target, PropertyInfo property)
{
object value = property.GetValue(target, null);
if (value == null)
{
string warning = string.Format("{0} doesn't support {1} types", typeof(ShowNativePropertyNativePropertyDrawer).Name, "Reference");
EditorDrawUtility.DrawHelpBox(warning, MessageType.Warning, context: target);
}
else if (!EditorDrawUtility.DrawLayoutField(value, property.Name))
{
string warning = string.Format("{0} doesn't support {1} types", typeof(ShowNativePropertyNativePropertyDrawer).Name, property.PropertyType.Name);
EditorDrawUtility.DrawHelpBox(warning, MessageType.Warning, context: target);
}
}
}
}