public class bian : MonoBehaviour {
public List<GameObject> golist = new List<GameObject>();
public List<GameObject> temp = new List<GameObject>();
float elapse = 3f;
// Use this for initialization
void Start () {
golist.Add(gameObject);
golist[0].AddComponent<Rigidbody>().useGravity = false;
}
// Update is called once per frame
void Update () {
if (elapse<=Time.time&&cr1==false)
{
clo();
elapse += 3;
}
}
void clo()
{
//遍历golist
foreach (var item in golist)
{
//复制每一个元素
GameObject newgo = GameObject.Instantiate(item);
//获取新创建gameobject下的脚本
bian b = newgo.GetComponent<bian>();
//删除
Destroy(b);
temp.Add(newgo);
}
golist.AddRange(temp);
temp.Clear();
}
}