- Home /
each instantiation getting it's own draw call?
Here is an example of draw calls skyrocketing when i try to instantiate a particle prefab on items in the scene that have a value set to true. Shouldn't all the instantiated particle prefabs be on the same draw call? or is it that it get's it's own because they don't happen at the exact same time? (given the loop i run through) any tips are greatly appreciated!
var startBoardExplosionAsset : GameObject; //linked through the inspector
itemsArray = GameObject.FindGameObjectsWithTag("item");
for (currentItem in itemsArray){ var currentScript : touchingThreeScore = (currentItem.GetComponent(touchingThreeScore) as touchingThreeScore);
if(currentScript.worthPoints == true){
var startBoardExplosion : GameObject = (Instantiate(startBoardExplosionAsset, currentItem.transform.position, currentItem.transform.rotation) as GameObject);
}
}
//where touchingThreeScore is the name of the script with the boolean 'worthPoints' var is
Answer by Eric5h5 · Jan 17, 2011 at 06:38 PM
All separate objects add an additional draw call (or more, depending on rendering mode). Some objects can be combined using static or dynamic batching, depending on certain conditions, but particle systems will never be combined.
(By the way, you can make shorter code by changing
var currentScript : touchingThreeScore = (currentItem.GetComponent(touchingThreeScore) as touchingThreeScore);
to
var currentScript = currentItem.GetComponent.<touchingThreeScore>();
You can also change
var startBoardExplosion : GameObject = (Instantiate(startBoardExplosionAsset, currentItem.transform.position, currentItem.transform.rotation) as GameObject);
to
Instantiate(startBoardExplosionAsset, currentItem.transform.position, currentItem.transform.rotation);
since you're apparently not using the startBoardExplosion variable for anything.)