Odin
// 选取后缀为.unity文件路径
[FilePath(Extensions = ".unity")]
public string ScenePath;
// 按钮
[Button(ButtonSizes.Large)]
public void SayHello()
{
Debug.Log("Hello button!");
}
// inspector面板上的标题栏
[Title("Wide Vector")]
// 能隐藏掉属性名称WideColor1的显示
[HideLabel]
[ColorPalette("Fall")]
public Color WideColor1;
// 表示此属性需要一个值, 以红色感叹号警告, 并传递一个字符串
[Required("$DynamicMessage")]
public GameObject GameObject;
public string DynamicMessage = "Dynamic error message";

// 隐藏了属性名称Name标签, 在没有值的情况下显示警告, 排序
[HideLabel, Required, PropertyOrder(-5)]
[ShowInInspector]
public string Name { get; set; }
[Button(ButtonSizes.Medium), PropertyOrder(-3)]
public void RandomName() =>
this.Name = Guid.NewGuid().ToString();
[PreviewField, Required, AssetsOnly]
public GameObject Prefab;
组属性布局
// PreviewField(50) 参数:高度
[HorizontalGroup("Split", Width = 50), HideLabel, PreviewField(50)]
public Texture2D Icon;
[VerticalGroup("Split/Properties")]
public string MinionName;
[VerticalGroup("Split/Properties")]
public float Health;
[VerticalGroup("Split/Properties")]
public float Damage;

[LabelText("$IAmLabel")]
public string IAmLabel;
// 注册增加和移除的函数调用
[ListDrawerSettings(
CustomAddFunction = "CreateNewGUID",
CustomRemoveIndexFunction = "RemoveGUID")]
public List<string> GuidList;
private string CreateNewGUID()
{
return Guid.NewGuid().ToString();
}
private void RemoveGUID(int index)
{
this.GuidList.RemoveAt(index);
}
// 分Tab页
[TabGroup("First Tab")]
public int FirstTab;

[Button(ButtonSizes.Large)]
[FoldoutGroup("Buttons in Boxes")]
[HorizontalGroup("Buttons in Boxes/Horizontal", Width = 60)]
[BoxGroup("Buttons in Boxes/Horizontal/One")]
public void Button1() { }
[Button(ButtonSizes.Large)]
[BoxGroup("Buttons in Boxes/Horizontal/Two")]
public void Button2() { }
[Button]
[BoxGroup("Buttons in Boxes/Horizontal/Double")]
public void Accept() { }
[Button]
[BoxGroup("Buttons in Boxes/Horizontal/Double")]
public void Cancel() { }
// 验证值
[ValidateInput("IsValid")]
public int GreaterThanZero;
private bool IsValid(int value)
{
return value > 0;
}
[OnValueChanged("UpdateRigidbodyReference")]
public GameObject Prefab;
private Rigidbody prefabRigidbody;
private void UpdateRigidbodyReference()
{
if (this.Prefab != null)
{
this.prefabRigidbody = this.Prefab.GetComponent<Rigidbody>();
}
else
{
this.prefabRigidbody = null;
}
}
// 属性表达式@符号开头
[InfoBox("@myStr")]
public string myStr;
// 始终显示当前时间的信息框
[InfoBox(@"@""The current time is: "" + DateTime.Now.ToString(""HH:mm:ss"")")]
public string myStr;
[ShowIf("@this.someNumber >= 0f && this.someNumber <= 10f")]
public string myStr;
public float someNumber;
// $property关键字可让您访问InspectorProperty
[LabelText("$IAmLabel")]
public string IAmLabel;
public class Example
{
[InfoBox(@"@""This member's parent property is called "" + $property.Parent.NiceName")]
public string myStr;
}
// 现在,在声明myStr的任何地方,myStr都会动态地知道它的父类的名称
public Example exampleInstance;
RequireComponent需求组件AssetsOnly仅资产可填FilePath, when RequireExistingPath is set to true 文件路径FolderPath, when RequireExistingPath is set to true 文件夹路径ChildGameObjectsOnly子游戏对象SceneObjectsOnly场景对象DetailedInfoBoxwhen an error is shown 详细信息框InfoBoxwhen an error is shown 提示信息框Required需要ValidateInput验证输入MinValue最小值MaxValue最大值Range and PropertyRange范围 和属性范围MinMaxSlider滑动区间

常用特性
Button
绘制一个按钮
ButtonSizes:按钮大小
name:按钮名称
ButtonStyle:按钮样式
Range
绘制一个有范围的滚动条
min:最小值
max:最大值
EnumToggleButtons
绘制水平枚举类型的单选框
ColorPalette
颜色选择面板,可自定义
AssetList
为asset文件绘制一个List
InlineEditor
预览unity内置的objects,例如shader,animation
PreviewWidth:预览宽度
PreviewHeight:预览高度
IncrementInlineEditorDrawerDepth:允许绘制递增
Expanded:允许拉伸
DrawHeader:绘制标题头
ProgressBar
绘制进度条
min:进度条最小值
max:进度条最大值
Segmented:允许进度条分段显示
ColorMember:可自定义颜色
BackgroundColorMember:背景颜色
BoxGroup
绘制包围盒
ShowLabel:显示标题文字
CenterLabel:居中显示标题文字
ValueDropdown
值的下拉列表
Multiline
绘制一个可编辑的string框
lines:行数
MultiLineProperty
类似于Multiline,但是可以用于字段和属性
TableMatrix
绘制矩阵形式
TableList
平铺显示所有属性
ShowIndexLabels:显示序号
DrawScrollView:使用滚动条
ShowPaging:分页显示
TabGroup
分组显示
VerticalGroup
垂直分布的组
groupId:所属group名称
order:层级
HorizontalGroup
水平分布的组
groupId:所属group名称
order:层级
FoldoutGroup
分页显示组别
BoxGroup
包围盒显示
ToggleGroup
单选组