在Unity编辑器中显示自定义struct需要在struct上使用Unity提供的属性,例如[System.Serializable]和[SerializeField]。
首先,在struct定义前加上[System.Serializable]属性,以告诉Unity该struct可以被序列化:
[System.Serializable]
public struct MyStruct {
public int a;
public float b;
public string c;
}