百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
N

NaughtyAttributes

> 开发工具
开源

Unity 的属性扩展

5.2K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Unity 的属性扩展

NaughtyAttributes

NaughtyAttributes 是一个 Unity Inspector 的扩展。

它扩展了 Unity 提供的属性(Attribute)范围,让你无需编写自定义编辑器或属性绘制器(Property Drawer)即可创建功能强大的 Inspector。它还提供了可应用于非序列化字段或函数的属性。

大多数特性都是通过 Unity 的 CustomPropertyDrawer 实现的,因此它们可以在你的自定义编辑器中使用。 在你的自定义编辑器中无法使用的特性是元特性(meta attributes)以及一些 drawer 特性,例如 ReorderableList、Button、ShowNonSerializedField 和 ShowNativeProperty。 不过,如果你希望所有特性都能在你的自定义编辑器中使用,你必须继承 NaughtyInspector,并使用 NaughtyEditorGUI.PropertyField_Layout 函数来代替 EditorGUILayout.PropertyField。

文档

安装

NaughtyAttributes 需要 2022.3 或更高版本。

  1. 该包可在 openupm registry 上获取。你可以通过 openupm-cli 进行安装。
openupm add com.dbrizov.naughtyattributes
  1. 你也可以通过 git url 安装,只需在 manifest.json 中添加以下条目
"com.dbrizov.naughtyattributes": "https://github.com/dbrizov/NaughtyAttributes.git#upm"
  1. 你也可以从 Asset Store 下载

概述

特殊特性(Attribute)

AllowNesting

在某些情况下,当你希望元特性(meta attributes)在可序列化的嵌套结构体或类中生效时,必须使用此特性。 你可以在这里查看哪些情况需要使用它。

csharp
public class NaughtyComponent : MonoBehaviour
{
    public MyStruct myStruct;
}

[System.Serializable]
public struct MyStruct
{
    public bool enableFlag;

    [EnableIf("enableFlag")]
    [AllowNesting] // Because it's nested we need to explicitly allow nesting
    public int integer;
}

Drawer 特性

为序列化字段提供特殊的绘制选项。

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#attributesextensionnaughtyunity3d

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具