我在将 a 添加GameObject
到 a时遇到问题List<>
。当我构建这个程序时,会发生错误poolInstances.Add(clone)
:
错误:List.Add(RecyclingGameObject) 有一些无效参数。
线上也出现错误return clone;
:
错误:无法将 Gameobject 隐式转换为 RecyclingGameObject
这是我的代码:
using System.Collections;
using System.Collections.Generic;
public class ObjectPool : MonoBehaviour {
public RecyclingGameObjects prefabs;
private List<RecyclingGameObjects> poolInstances = new List<RecyclingGameObjects();
private RecyclingGameObjects createInstance(Vector3 pos){
var clone = GameObject.Instantiate (prefabs) as GameObject ;
clone.transform.position = pos;
clone.transform.parent = transform;
poolInstances.Add (clone);
return clone;
}
}