Unity3d学习日记:使用[System.Serializable]
发表于2018-02-12
在unity里,自定义数据类型无法显示在inspectior面板里,需要对定义数据类型的类或者结构体使用[System.Serializable]。效果如图:
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Test : MonoBehaviour { public A[] AList; public B[] BList; public A a; public B b; // Use this for initialization void Start () { } // Update is called once per frame void Update () { } } [System.Serializable] public struct A { public int a; public GameObject b; public Vector3 c; } public struct B { public int a; public GameObject b; public Vector3 c; }
可以看到,结构体B的数据无法再面板内显示,而A的则可以显示。
如社区发表内容存在侵权行为,您可以点击这里查看侵权投诉指引