Hello Guest

Author Topic: How much performance do all the options cost?  (Read 4501 times)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9673
    • View Profile
How much performance do all the options cost?
« 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 different vertex counts requires memory allocation. This is not a good idea at runtime. You will be shown a warning in the SpriteAnimation editor if you do this to alert you to the potential problem.
  • Changing maxChars on a TextMesh will reallocate memory. This is bad at runtime.


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.
« Last Edit: April 29, 2013, 11:25:15 AM by unikronsoftware »