0
votes

I am making an interactive book application that player will curl pages and will see spritesheet animations per page. I have tried to load sprites seperately(300 images with 512x512 size). But when i tried this method, ipad crashes and saying about memory issue. I have checked memory profile on unity and the application was loading '1.2 GB' into ram. It's so huge so ipad is right.

So first thing i think that I need to load only specify number of pages and when player turns pages to forward, I may load new assets and destroy previous page assets. When I tried it, when player turns the page, its freezing some seconds to load new sprites and its too bad for user experience.

Second thing I am thinking right now, let's say i have 30 frames for 1 sprite animation, just putting 30 frames into a texture and use only this texture for sprite animation. I mean that instead of using 30 different images, I need to use 1 sprite atlas texture which contains all frames, and I can change rect in runtime to present sprite animation. But I don't know how can I use only 1 texture to present 30 frames?

1

1 Answers

0
votes

When I tried it, when player turns the page, its freezing some seconds to load new sprites and its too bad for user experience

Assuming this is a linear setup, you can just store plus or minus 5 pages at a time. If I'm on page 1, load page 2-6, when I turn the page, load page 7. when I get to page 6, remove page 1. There will be a trade off of performance vs memory allocation, so you will have to make the call of how many pages to cache.

But I don't know how can I use only 1 texture to present 30 frames?

I'm not sure how you have your sprite texture set up, but you can make a sprite into multiple sprites by setting the spriteImportMode to SpriteImportMode.Multiple. You can then define the bounds of each sprite via the parent sprites spriteMetaData. You can also change this in the unity editor, but from what you are describing, you will have to do it programatically.

I'm fairly certain that this is not the ideal path to go down. You may want to look into Unity Tilemaps to come up with a more robust answer.