ECM2
This commit is contained in:
33
Assets/VolumetricLightBeam/Scripts/HighlightNullAttribute.cs
Normal file
33
Assets/VolumetricLightBeam/Scripts/HighlightNullAttribute.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace VLB
|
||||
{
|
||||
/// <summary>
|
||||
/// Highlight in red in inspector in not set
|
||||
/// </summary>
|
||||
public sealed class HighlightNullAttribute : PropertyAttribute { }
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[CustomPropertyDrawer(typeof(HighlightNullAttribute))]
|
||||
public class HighlightNullDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
if (property.propertyType != SerializedPropertyType.ObjectReference)
|
||||
{
|
||||
EditorGUI.LabelField(position, label.text, "Only valid for object references");
|
||||
return;
|
||||
}
|
||||
|
||||
if (property.objectReferenceValue == null)
|
||||
EditorGUI.DrawRect(position, Color.red);
|
||||
|
||||
EditorGUI.ObjectField(position, property, label);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user