【发布时间】:2021-10-06 04:09:19
【问题描述】:
我在 Unity 中有以下代码
public class Objects : MonoBehaviour
{
List<GridObject> Grid = new List<GridObject>();
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
Grid.Add( new (GridObject) {xCord = 0, zCord = 0, ObjectID = 0});
}
}
它给出了错误:“元组必须包含至少两个元素”在 GameObject 我认为它与 new() 函数有关,但我不知道如何
【问题讨论】:
-
为什么
GridObject用括号括起来?是错字吗? -
您的意思是
new GridObject()吗? -
@derHugo 是的,那是正确的
-
@gunr2171 不,这不仅仅是一个错字,我认为这是正确的
标签: c# unity3d arraylist new-operator