2
我想通过构造一个新的asd然后添加一个新的asd类来添加一个新的asd类实例,但是Unity给出的对象没有设置为对象错误的实例。如何将新对象添加到没有变量的列表中?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class asd {
public int a = 0;
public string s = "asd";
public asd (int apop, string ssdf) {
a = apop;
s = ssdf;
}
}
public class test : MonoBehaviour {
public List<asd> list;
// Use this for initialization
void Start() {
list.Add (new asd(1, "yeee"));
list.Add (new asd(456, "oooo"));
}
// Update is called once per frame
void Update() {
}
}
@MXD这看起来像一个快速代码示例,名称为'test'。 –
@MXD您的评论不具建设性和粗鲁。 – Nasreddine
是的,这是一个测试,这就是为什么这些名字都很糟糕。 –