2D Toolkit Forum

2D Toolkit => FAQs => Topic started by: unikronsoftware on January 26, 2012, 07:06:08 pm

Title: How much performance do all the options cost?
Post by: unikronsoftware on January 26, 2012, 07:06:08 pm
A base sprite is simply a mesh in Unity, and it would be no different if you built the polygons in your favourite 3d program.
You only incur a cost when you update the sprite or text mesh, i.e. change the sprite id, color, text, etc.

Certain operations are more expensive than others and these are listed below:



Switching sprite ids with the same vertex counts, changing scale or colors incur about the same cost.
No allocation is performed here, but vertex buffers need to be updated.

Changing scale and color is dependent on the number of vertices. You should avoid doing this at runtime on massively diced sprites, and doing this on text meshes is directly a function of the number of characters in the mesh.

Collider overheads - if you have colliders set up, and you move/scale/rotate the sprite, make sure to have a kinematic rigidbody set. That is unless you have very few of them that it doesn't matter.

GameObject overhead - you are very likely to run into GameObject/Unity object overheads if you have too many GameObjects / tk2dSprites / etc. Use the static sprite batcher where you can to merge static background sprites efficiently.