Odin - Inspector and Serializer 使用手札

Odin - Inspector and Serializer

Odin - Inspector and Serializer 是Unity一个超级好用的编辑器扩展插件.

0a15170a-a8f1-4343-a0d1-99718c9bee52

如果还没有用过,建议去尝试一下.

手札

修改在Inspector中显示的名字

1
2
[LabelText("血量")]
public int blood;

如果条件达成则显示

标签包含 ShowIf,HideIf,EnableIf,DisableIf, 同时支持枚举类型

1
2
3
4
5
6
public bool isShowBlood;

[ShowIf("isShowBlood"),[LabelText("血量")]]
public int blood;

1.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public enum InfoMessageType
{
None,
Info,
Warning,
Error,
}

public class ShowAndHideIfExamples : MonoBehaviour
{
[EnumToggleButtons]
public InfoMessageType SomeEnum;

public bool IsToggled;

[ShowIf("SomeEnum", InfoMessageType.Info)]
public Vector3 Info;

[ShowIf("SomeEnum", InfoMessageType.Warning)]
public Vector2 Warning;

[ShowIf("SomeEnum", InfoMessageType.Error)]
public Vector3 Error;

[ShowIf("IsToggled")]
public Vector2 VisibleWhenToggled;

[HideIf("IsToggled")]
public Vector3 HiddenWhenToggled;
}
坚持原创技术分享,您的支持将鼓励我继续创作!