先初始化 PoolManager,确保 SpawnPool里面 生成 有对应 名称 的物体,(这一步 代码 在 相关资料 1)
要通过物体名称查找&新建 物体,都是通过 Spawn函数进行。
SpawnPool.cs的
...
//658 /// <summary>
/// See primary Spawn method for documentation.
///
/// Overload to take only a prefab name. The cached reference is pulled
/// from the SpawnPool.prefabs dictionary.
/// </summary>
public Transform Spawn(string prefabName)
{
Transform prefab = this.prefabs[prefabName];
return this.Spawn(prefab);
}
...
...
Transform trans = spawnPool.Spawn(GOName);
...
...
public GameObject go1;
public GameObject go2;
public GameObject go3;
public GameObject go4;
...
go1 = spawnPool.Spawn("Cube").gameObject