0
\$\begingroup\$

Quite some time ago I made a "GIF player" that basically reads a sprite array and swaps the sprite using a Coroutine, one after the other, in order to imitate a "GIF" animation.

I was working but I have no clue about performance as on my PC it was fine.

Thing is, the game is meant for mobile and I experience some lag and I don't know if it is due to my not using sprite sheet animations instead of my shiny solution.

The question is: Is there some difference between the sprite sheet anim and swapping sprites from an array? I know Unity's API (that I used) cannot be called from other than the main thread. What about sprite sheet animations? Using another thread would definitely help but I can't do that and maybe they could.

\$\endgroup\$
1
\$\begingroup\$

It could be due to a lot of reasons. Most of them maybe aren't even related to that..?

But, about performance, using a spritesheet should always be better than manually swaping sprites.

The probably best solution would be to use a custom shader which makes use of a Texture2DArray to play the animation. But that is quite harder than making a spritesheet.

\$\endgroup\$
  • \$\begingroup\$ I plan to use the spritesheet then, no matter if it's just a small performance improvement, it's still an improvement. Thanks! \$\endgroup\$ – agiro Aug 22 '17 at 7:53
1
\$\begingroup\$

I'd just like to add that you can view relevant performance stats, like draw calls, by selecting stats under the game tab in the Unity editor.

A sprite sheet is generally useful for reducing draw calls as the entire sheet can be pushed to the graphics card instead of each sprite individually (a costly operation). Have a search for "unity sprite sheet draw calls".

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.