2D Toolkit Forum

2D Toolkit => Support => Topic started by: erfan71 on February 21, 2014, 08:52:49 am

Title: tk2SpriteAnimator.LateUpdate() Very High CPU Impact !!
Post by: erfan71 on February 21, 2014, 08:52:49 am
Hi !.
I use Unity Profiler to test my Performance ,  i See that tk2SpriteAnimator.LateUpdate() have a vary High CPU Time , and i worry about it . it some times goes up to 1.2 ms !!!!
I just Have 2 SpriteAnimator in my Scene.
One for Runner Player , and the other for coins that Rotate in the Scene . ( i see 4 up to 5 coins at the same time in the camera )
How can i Optimize this function ?
reduse the frameRate? Reduse the Atlas Sizes? 
Title: Re: tk2SpriteAnimator.LateUpdate() Very High CPU Impact !!
Post by: unikronsoftware on February 21, 2014, 10:40:12 am
Is it allocating any memory at that point? One reason for it to allocate memory is if you're using sprite dicing, etc on the sprite. You don't want to do that on animators unless you can handle the overhead. Also, is it REALLY the animator, and not the garbage collector, etc underneath it?

I can't say I've seen 1 or 2 sprites causing issues like that. Try the tile map demo, there are LOADS of coins there.
Title: Re: tk2SpriteAnimator.LateUpdate() Very High CPU Impact !!
Post by: erfan71 on February 22, 2014, 06:16:34 pm
No, My animation are not Dice.  but they are a little complex , about 30 images.
Title: Re: tk2SpriteAnimator.LateUpdate() Very High CPU Impact !!
Post by: unikronsoftware on February 22, 2014, 10:37:17 pm
Number of images shouldn't really matter, unless you're constantly swapping materials because you're using spanning.
How many sprite animator.update does the profiler report? You say you had 2 in the scene, but then you say you have 4-5 coins rotating as well so it can't be 2 can it?