转载:http://blog.csdn.net/liqiangeastsun/article/details/42101989
Unity中默认只在Inspecotr面板上显示基本类型数据, 如 int, float, string, Rect等基本类型。
经常会用到一些类,希望显示在Inspecotr面板上.
需要在定义类前写写一行代码 [System.Serializable]
即将类对象序列化,代码如下
using UnityEngine;
using System.Collections;
[System.Serializable]
public class MyClass
{
public int num;
public string data;
public MyClass()
{
num = 1;
data = "ABC";
}
}
public class Test : MonoBehaviour {
public int nnn;
public float mmm;
public MyClass SelfClass;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}