[Unity, 笔记] 在 Inspector 中显示结构体, 结构体的序列化

在 Unity 中的 Inspector, 基本数据类型, 数组, 都是可以直接显示出来的, 但创建出来的结构体不能直接显示出来.

为结构体添加一个 System.Serializable 特性即可使其能够显示在 Inspector 中.

[Serializable]
struct CustomData
{
    
    
    public int SomeInteger;
    public string SomeString;
}

猜你喜欢

转载自blog.csdn.net/m0_46555380/article/details/132603584