unity的结构体中数组的使用

Posted moyaoqueen

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了unity的结构体中数组的使用相关的知识,希望对你有一定的参考价值。

tips

1.结构体中包含数组,在使用之前,必须实例化,并规定数组的长度;

2.new 出来的长度并不互相影响,new

struct test
{
public string[] strs;
}

test m_test = new test();

m_test.strs = new string[5];
Debug.Log(m_test.strs.Length);
m_test.strs = new string[2];
Debug.Log(m_test.strs.Length);
m_test.strs = new string[6];
Debug.Log(m_test.strs.Length);

 

输出的结果即为5,2,6.









以上是关于unity的结构体中数组的使用的主要内容,如果未能解决你的问题,请参考以下文章