简体   繁体   English

在每个元素之外定义变量时,列表上的Unity3d超出范围错误

[英]Unity3d out of range error on a list when defining variables out of each element

I have a list with which I want to define three variables out of it. 我有一个列表,我想从中定义三个变量。

YearText.text=CarInfoList[0].CarYear;
MakeText.text=CarInfoList[1].CarMake;
ModelText.text=CarInfoList[2].CarModel;

The list has one record set with the variable elements defined in a constructor script. 该列表具有一个记录集,其中包含在构造函数脚本中定义的变量元素。 The first line works just fine and displays as expected, but when I try the second or third, it give me an out of range error. 第一行工作正常,并按预期显示,但是当我尝试第二或第三行时,它给了我一个超出范围的错误。 Anyone have some thoughts? 有人有什么想法吗? Thanks! 谢谢!

you said right in your question that there is only one record set... 您说正确的问题是只有一个记录集...

you want this... 你要这个...

YearText.text=CarInfoList[0].CarYear;
MakeText.text=CarInfoList[0].CarMake;
ModelText.text=CarInfoList[0].CarModel;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM