module-project-validator/Editor/Window/Objects/EditorProjectValidatorEnabledPropertyDrawer.cs

23 lines
No EOL
1,021 B
C#

using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace Module.ProjectValidator.Editor
{
[CustomPropertyDrawer(typeof(ProjectValidatorSettings.ValidatorEnabled))]
internal sealed class EditorProjectValidatorEnabledPropertyDrawer : PropertyDrawer
{
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var spType = property.FindPropertyRelative(nameof(ProjectValidatorSettings.ValidatorEnabled.name));
var spEnabled = property.FindPropertyRelative(nameof(ProjectValidatorSettings.ValidatorEnabled.enabled));
var root = new VisualElement { style = { flexDirection = FlexDirection.Row } };
var veType = new PropertyField(spType, string.Empty) { style = { flexGrow = 1f }, enabledSelf = false };
var veEnabled = new PropertyField(spEnabled, string.Empty);
root.Add(veEnabled);
root.Add(veType);
return root;
}
}
}