unity中的attributes

Inspector相关

1.[PropertyAttribute]: 基类

2.[SerializeField]: 强制在Inspector中显示private变量
3.[HideInInspector]: 强制在Inspector中隐藏public变量

4.[TextAreaAttribute]: 在Inspector中为变量生成文本框
5.[Range(1,10)]: 在Inspector中生成滑动条
6.[Multiline(3)]: 使string的文本框支持多行

7.[Header(“xxx”)]: 在Inspector中生成标题文字
8.[Tooltip(“yyy”)]: 当鼠标移动到参数上时显示说明文字

1.[CreateAssetMenuAttribute]: 在Create菜单中新增一个类别

  • menuName:该类的显示名称
  • fileName:生成实例的默认文件名

例子

[][SerializeField] string storyText;