1.Serializable
The Serializable attribute lets you embed a class with sub properties in the inspector.
让你能够把它嵌入到另外一个class时在属性编辑器里能将其展开
[System.Serializable]
class Test{
public int p = 5;
public Color c = Color.white;
}
public class Test2:MonoBehaviour{
public Test[] t;
}
这样在编辑器里Test里的t是能进一步展开的,这个很有用
本文介绍了如何在Unity中使用[Serializable]属性来实现类及其子属性在Inspector面板中的可编辑性。通过示例代码展示了如何定义一个可展开的Test类,并在另一个类Test2中作为数组元素使用。
11万+

被折叠的 条评论
为什么被折叠?



