Hello Guest

Author Topic: tk2dSprite as monobehaviour  (Read 3067 times)

spinner

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
tk2dSprite as monobehaviour
« on: November 15, 2013, 03:23:19 pm »
Hello,
I was thinking about the overhead of adding a lot of sprites into a scene.
Since they inherit from MonoBehaviour, does that means that for everysprite unity runtime will iterate over its Update() method?

In that case, if I create a tilemap with let's say 200 tiles (sprites), the runtime will have to iterate over that 200 sprites each frame?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2dSprite as monobehaviour
« Reply #1 on: November 15, 2013, 05:04:46 pm »
Monobehaviours only incur a cost for the Update function when its actually used and present in the script. Update isn't virtual, so Unity doesn't go and iterate through everything calling update everywhere if an Update function doesn't exist in the script. tk2d Sprites don't have update functions, only animators do.

In any case, the tile map has an optimised code path that generates partitioned composite meshes. What that means is that your tile map is going to be grouped by 32x32 tiles by default (1024 sprites), and these will all be baked down to one game object.