This commit is contained in:
2025-05-16 23:31:59 +08:00
parent 9e4fef3f1e
commit d891e3f0ee
1198 changed files with 274242 additions and 1558 deletions

View 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
}