架构大更

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

@@ -2,8 +2,8 @@
namespace NaughtyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
[AttributeUsage(AttributeTargets.Field)]
public class EnumFlagsAttribute : DrawerAttribute
{
}
}
}

View File

@@ -2,8 +2,8 @@
namespace NaughtyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
[AttributeUsage(AttributeTargets.Field)]
public class ExpandableAttribute : DrawerAttribute
{
}
}
}

View File

@@ -2,19 +2,19 @@
namespace NaughtyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
[AttributeUsage(AttributeTargets.Field)]
public class ShowAssetPreviewAttribute : DrawerAttribute
{
public const int DefaultWidth = 64;
public const int DefaultHeight = 64;
public int Width { get; private set; }
public int Height { get; private set; }
public ShowAssetPreviewAttribute(int width = DefaultWidth, int height = DefaultHeight)
{
Width = width;
Height = height;
}
public int Width { get; private set; }
public int Height { get; private set; }
}
}
}

View File

@@ -2,8 +2,8 @@
namespace NaughtyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
[AttributeUsage(AttributeTargets.Field)]
public class TagAttribute : DrawerAttribute
{
}
}
}

View File

@@ -1,12 +1,12 @@
{
"name": "NaughtyAttributes.Core",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": []
"name": "NaughtyAttributes.Core",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": []
}

View File

@@ -2,14 +2,14 @@
namespace NaughtyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
[AttributeUsage(AttributeTargets.Field)]
public class RequiredAttribute : ValidatorAttribute
{
public string Message { get; private set; }
public RequiredAttribute(string message = null)
{
Message = message;
}
public string Message { get; private set; }
}
}
}

View File

@@ -1,16 +1,16 @@
{
"name": "NaughtyAttributes.Editor",
"references": [
"NaughtyAttributes.Core"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
"name": "NaughtyAttributes.Editor",
"references": [
"NaughtyAttributes.Core"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

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);
}
}
}
}

View File

@@ -1,14 +1,14 @@
{
"name": "NaughtyAttributes.Test",
"references": [
"NaughtyAttributes.Core"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
"name": "NaughtyAttributes.Test",
"references": [
"NaughtyAttributes.Core"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System;
using UnityEngine;
namespace NaughtyAttributes.Test
@@ -7,13 +7,13 @@ namespace NaughtyAttributes.Test
{
}
[System.Serializable]
[Serializable]
public class MyClass
{
}
[System.Serializable]
[Serializable]
public struct MyStruct
{
}
}
}

View File

@@ -1,12 +1,11 @@
using UnityEngine;
using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine;
namespace NaughtyAttributes.Test
{
//[CreateAssetMenu(fileName = "TestScriptableObjectA", menuName = "NaughtyAttributes/TestScriptableObjectA")]
public class _TestScriptableObjectA : ScriptableObject
{
[Expandable]
public List<_TestScriptableObjectB> listB;
[Expandable] public List<_TestScriptableObjectB> listB;
}
}

View File

@@ -4,7 +4,11 @@
"version": "2.1.4",
"unity": "2018.4",
"description": "NaughtyAttributes is an extension for the Unity Inspector.",
"keywords": [ "attribute", "inspector", "editor" ],
"keywords": [
"attribute",
"inspector",
"editor"
],
"category": "editor extensions",
"dependencies": {},
"samples": [