Added custom inspector for VolumeObject; Change the name of AoVolume to VolumeObject;
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace Misaki.AoVolume.Editor
|
|
{
|
|
[CustomPropertyDrawer(typeof(PopupBooleanAttribute))]
|
|
public class PopupBooleanDrawer : PropertyDrawer
|
|
{
|
|
private static readonly GUIContent[] _popupContent = { new("False"), new("True") };
|
|
private static readonly List<bool> _popupOptions = new() { false, true };
|
|
|
|
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
|
{
|
|
var value = property.boolValue;
|
|
var index = value ? 1 : 0;
|
|
|
|
EditorGUI.BeginChangeCheck();
|
|
index = EditorGUI.Popup(position, label, index, _popupContent);
|
|
if (EditorGUI.EndChangeCheck())
|
|
{
|
|
property.boolValue = index == 1;
|
|
}
|
|
}
|
|
|
|
public override VisualElement CreatePropertyGUI(SerializedProperty property)
|
|
{
|
|
var popupField = new PopupField<bool>(property.displayName, _popupOptions, false);
|
|
popupField.AddToClassList(PopupField<bool>.alignedFieldUssClassName);
|
|
popupField.bindingPath = property.propertyPath;
|
|
|
|
return popupField;
|
|
}
|
|
}
|
|
} |