Post by baroquedub on Jan 19, 2017 23:35:38 GMT
A bit new to pooling so apologies for what may be a newbie question...
I'm going through my scripts to replace all instances of Instantiated prefabs (bullets, bulletHit decals, explosions, etc.) with Spawned items.
So I've added all my prefabs in PoolBoss:
etc...
Reading through the docs and forum it appears that I should be going through my scripts and replacing:
with
but I'm wondering if someone could explain what the difference is between the above, and other variations like;
i.e. referencing not the prefab on the bullet firing script (as per the original), but instead using the name of the item in the pool (as a string)
a. Does it matter if I do a quick 'lazy' replace? Does PoolBoss do a look up to check that this transform actually exists as an item in the pool?
b. Do you get better performance if you change the references from a prefab dropped on the firing script, to the actual name of the item?
(I'm working in mobile VR where every once of performance matters)
In other words, is it worth my while going through each script and adding a new string variable (and after testing removing the old prefab reference):
Also, what's the difference between SpawnOutsidePool and SpawnInPool?
- I understand that the first creates the spawned prefab with no parent transform, while the other creates a child of PoolBoss
but what's the difference (advantages/disadvantages/usecase) of either option?
Does either make any difference to how these prefabs are despawned and reused?
If the prefabs (bullets, bulletHit decals, etc) despawn on collision or after a set time, does either make any difference?
What's best practice?
As always, any help or advice would be much appreciated
I'm going through my scripts to replace all instances of Instantiated prefabs (bullets, bulletHit decals, explosions, etc.) with Spawned items.
So I've added all my prefabs in PoolBoss:
etc...
Reading through the docs and forum it appears that I should be going through my scripts and replacing:
GameObject bullet = (GameObject)(Instantiate(bulletObject, bulletSpawn.position, fireRotation));
with
GameObject bullet = PoolBoss.SpawnOutsidePool(bulletObject.transform, bulletSpawn.position, fireRotation).gameObject;
but I'm wondering if someone could explain what the difference is between the above, and other variations like;
GameObject bullet = PoolBoss.SpawnOutsidePool(bulletObjectNameInPool, bulletSpawn.position, fireRotation).gameObject;
i.e. referencing not the prefab on the bullet firing script (as per the original), but instead using the name of the item in the pool (as a string)
a. Does it matter if I do a quick 'lazy' replace? Does PoolBoss do a look up to check that this transform actually exists as an item in the pool?
b. Do you get better performance if you change the references from a prefab dropped on the firing script, to the actual name of the item?
(I'm working in mobile VR where every once of performance matters)
In other words, is it worth my while going through each script and adding a new string variable (and after testing removing the old prefab reference):
Also, what's the difference between SpawnOutsidePool and SpawnInPool?
- I understand that the first creates the spawned prefab with no parent transform, while the other creates a child of PoolBoss
but what's the difference (advantages/disadvantages/usecase) of either option?
Does either make any difference to how these prefabs are despawned and reused?
If the prefabs (bullets, bulletHit decals, etc) despawn on collision or after a set time, does either make any difference?
What's best practice?
As always, any help or advice would be much appreciated