Merge pull request #8 from angusmf/master
Allow pasing array of objects to CreatePool, such as from a sceneobje…
This commit is contained in:
commit
6a586f68b6
@ -21,6 +21,20 @@ namespace MLAPI.Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal NetworkPool(GameObject[] prefabs, string name)
|
||||||
|
{
|
||||||
|
objects = prefabs;
|
||||||
|
poolName = name;
|
||||||
|
int size = prefabs.Length;
|
||||||
|
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
prefabs[i].name = "Pool " + poolName + " #" + i;
|
||||||
|
prefabs[i].SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
internal GameObject SpawnObject(Vector3 position, Quaternion rotation)
|
internal GameObject SpawnObject(Vector3 position, Quaternion rotation)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < objects.Length; i++)
|
for (int i = 0; i < objects.Length; i++)
|
||||||
|
@ -31,6 +31,24 @@ namespace MLAPI.NetworkingManagerComponents
|
|||||||
Pools.Add(poolName, new NetworkPool(poolPrefab, size, poolName));
|
Pools.Add(poolName, new NetworkPool(poolPrefab, size, poolName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void CreatePool(string poolName, GameObject[] poolPrefabs)
|
||||||
|
{
|
||||||
|
if (Pools.ContainsKey(poolName))
|
||||||
|
{
|
||||||
|
Debug.LogWarning("MLAPI: A pool with the name " + poolName + " already exists");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (poolPrefabs == null)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("MLAPI: A pool prefab array is required");
|
||||||
|
}
|
||||||
|
PoolIndexToPoolName.Add(PoolIndex, poolName);
|
||||||
|
PoolNamesToIndexes.Add(poolName, PoolIndex);
|
||||||
|
PoolIndex++;
|
||||||
|
Pools.Add(poolName, new NetworkPool(poolPrefabs, poolName));
|
||||||
|
}
|
||||||
|
|
||||||
public static GameObject SpawnPoolObject(string poolName, Vector3 position, Quaternion rotation)
|
public static GameObject SpawnPoolObject(string poolName, Vector3 position, Quaternion rotation)
|
||||||
{
|
{
|
||||||
if(NetworkingManager.singleton.isServer)
|
if(NetworkingManager.singleton.isServer)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user