public NetworkGameObjectPool GetPoolForObject(string i_ObjectPoolTag) { NetworkGameObjectPool returnedPool = null; try { returnedPool = m_ObjectPoolDictionary[i_ObjectPoolTag]; } catch (KeyNotFoundException ex) { Debug.LogError(string.Format("The requested tag wasn't found in the dictionary.{0}Make sure that the tag is correct and that a pool by that name exists in your inspector.{0}{1}", Environment.NewLine, ex.Message)); } return(returnedPool); }
void Start() { if (isServer) { m_Instance = this; if (GameObject.FindObjectsOfType(this.GetType()).Length > 1) { Debug.LogError("Can't have more than one Object Pool Manager in a scene."); } for (int i = 0; i < ObjectPoolStartAmounts.Count; ++i) { m_ObjectPoolDictionary.Add(ObjectPoolNames[i], null); m_ObjectPoolDictionary[ObjectPoolNames[i]] = new NetworkGameObjectPool(); for (int j = 0; j < ObjectsToPool[i].InnerList.Count; ++j) { m_ObjectPoolDictionary[ObjectPoolNames[i]].AddSource(ObjectsToPool[i].InnerList[j], ObjectPoolStartAmounts[i].InnerList[j]); } } } }
void Start() { if (isServer) { m_Instance = this; if (GameObject.FindObjectsOfType(this.GetType()).Length > 1) { Debug.LogError("Can't have more than one Object Pool Manager in a scene."); } for(int i = 0; i < ObjectPoolStartAmounts.Count; ++i) { m_ObjectPoolDictionary.Add(ObjectPoolNames[i], null); m_ObjectPoolDictionary[ObjectPoolNames[i]] = new NetworkGameObjectPool(); for (int j = 0; j < ObjectsToPool[i].InnerList.Count; ++j) { m_ObjectPoolDictionary[ObjectPoolNames[i]].AddSource(ObjectsToPool[i].InnerList[j], ObjectPoolStartAmounts[i].InnerList[j]); } } } }