架构大更

This commit is contained in:
SoulliesOfficial
2026-03-20 11:56:50 -04:00
parent e60ef64d01
commit d09b58fd80
3663 changed files with 15232012 additions and 105579 deletions

View File

@@ -8,62 +8,48 @@ namespace NaughtyAttributes.Editor
public sealed override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
{
// Check if visible
bool visible = PropertyUtility.IsVisible(property);
if (!visible)
{
return;
}
var visible = PropertyUtility.IsVisible(property);
if (!visible) return;
// Validate
ValidatorAttribute[] validatorAttributes = PropertyUtility.GetAttributes<ValidatorAttribute>(property);
var validatorAttributes = PropertyUtility.GetAttributes<ValidatorAttribute>(property);
foreach (var validatorAttribute in validatorAttributes)
{
validatorAttribute.GetValidator().ValidateProperty(property);
}
// Check if enabled and draw
EditorGUI.BeginChangeCheck();
bool enabled = PropertyUtility.IsEnabled(property);
var enabled = PropertyUtility.IsEnabled(property);
using (new EditorGUI.DisabledScope(disabled: !enabled))
using (new EditorGUI.DisabledScope(!enabled))
{
OnGUI_Internal(rect, property, PropertyUtility.GetLabel(property));
}
// Call OnValueChanged callbacks
if (EditorGUI.EndChangeCheck())
{
PropertyUtility.CallOnValueChangedCallbacks(property);
}
if (EditorGUI.EndChangeCheck()) PropertyUtility.CallOnValueChangedCallbacks(property);
}
protected abstract void OnGUI_Internal(Rect rect, SerializedProperty property, GUIContent label);
sealed override public float GetPropertyHeight(SerializedProperty property, GUIContent label)
public sealed override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
bool visible = PropertyUtility.IsVisible(property);
if (!visible)
{
return 0.0f;
}
var visible = PropertyUtility.IsVisible(property);
if (!visible) return 0.0f;
return GetPropertyHeight_Internal(property, label);
}
protected virtual float GetPropertyHeight_Internal(SerializedProperty property, GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, includeChildren: true);
return EditorGUI.GetPropertyHeight(property, true);
}
protected float GetPropertyHeight(SerializedProperty property)
{
SpecialCaseDrawerAttribute specialCaseAttribute = PropertyUtility.GetAttribute<SpecialCaseDrawerAttribute>(property);
if (specialCaseAttribute != null)
{
return specialCaseAttribute.GetDrawer().GetPropertyHeight(property);
}
var specialCaseAttribute = PropertyUtility.GetAttribute<SpecialCaseDrawerAttribute>(property);
if (specialCaseAttribute != null) return specialCaseAttribute.GetDrawer().GetPropertyHeight(property);
return EditorGUI.GetPropertyHeight(property, includeChildren: true);
return EditorGUI.GetPropertyHeight(property, true);
}
public virtual float GetHelpBoxHeight()
@@ -71,18 +57,19 @@ namespace NaughtyAttributes.Editor
return EditorGUIUtility.singleLineHeight * 2.0f;
}
public void DrawDefaultPropertyAndHelpBox(Rect rect, SerializedProperty property, string message, MessageType messageType)
public void DrawDefaultPropertyAndHelpBox(Rect rect, SerializedProperty property, string message,
MessageType messageType)
{
float indentLength = NaughtyEditorGUI.GetIndentLength(rect);
Rect helpBoxRect = new Rect(
var indentLength = NaughtyEditorGUI.GetIndentLength(rect);
var helpBoxRect = new Rect(
rect.x + indentLength,
rect.y,
rect.width - indentLength,
GetHelpBoxHeight());
NaughtyEditorGUI.HelpBox(helpBoxRect, message, MessageType.Warning, context: property.serializedObject.targetObject);
NaughtyEditorGUI.HelpBox(helpBoxRect, message, MessageType.Warning, property.serializedObject.targetObject);
Rect propertyRect = new Rect(
var propertyRect = new Rect(
rect.x,
rect.y + GetHelpBoxHeight(),
rect.width,
@@ -91,4 +78,4 @@ namespace NaughtyAttributes.Editor
EditorGUI.PropertyField(propertyRect, property, true);
}
}
}
}