在学习unity 时遇到inspector面板无法显示二维数组是令人头疼的一件事,网上找了资料,有人认为要自己写一个编辑器布局,但这种方法有点麻烦,于是就找到另一种方法:
using UnityEngine;
using System.Collections;
public class GameManager : MonoBehaviour {
public CustomArrays[]
Arrays;
}
[System.Serializable]
public class CustomArrays
{
public float[]
Array;
public float this[int index]
{
get
{
return
Array[index];
}
}
public CustomArray()
{
this.Array= new float[4];
}
public CustomArray(int index)
{
this.Array= new float[index];
}
}
在Unity开发过程中,遇到Inspector面板无法显示二维数组时,可以通过自定义编辑器布局来解决。本文将介绍一种更简便的方法,通过创建`CustomArrays`类并实现序列化属性,使得二维数组在Inspector面板中得以正确展示。
856

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



