Memory Usage of Sprites

More
8 years 4 months ago #1606 by wagenheimer
I'm using I2 for localizing some sprites, and it works!

But it seems that All Sprites are loading in memory, even it's not being used by current language. Is this expected?

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago #1608 by Frank
Replied by Frank on topic Memory Usage of Sprites
It is expected If you are referencing the sprites directly.
This normally happens when your sprites are not in a Resources folder. In that case, the plugin has to add a reference to the sprites in the "Referenced Assets" section of the Localize component or the "Assets" tab in the I2Languages.prefab.
Given that they are referenced, then Unity loads them and keep them in memory.

To avoid this extra memory, move to the Resources folder all the sprites that change based on language.
When I2L finds a sprite in a Resources folder, it keeps its name and path instead of doing a reference. Then at runtime, whenever you try to use it by changing language, it just loads the sprite from the Resources folder. So, only the sprites of the current language are loaded in memory.

A third option is to use Bundles. In version 2.6.7f1 I added support for bundles.
In the Examples\Common\Script folder there is a class named RegisterBundlesManager.cs

That component, when attached to an object in your scene, it registers itself in the ResourcesManager and if the sprite can't be found in the Resources folder, the managers calls the LoadFromBundle function, allowing you to get the sprite from your bundles.

I also have scheduled for 2.6.8 to expand that example a bit and include a full bundle manager that could also download the bundle and re-localize things async once the requested assets are available.

Hope that helps,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago #1609 by wagenheimer
Replied by wagenheimer on topic Memory Usage of Sprites
Hummm... Thanks for the quick response! =)

I will try the tip of using the resources folder and will tell if it worked! =)

So... if I put my files on resources folder I don't need to manually link them on References of the Localize? You just saved me days of work if this is true! =)

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago - 8 years 4 months ago #1610 by Frank
Replied by Frank on topic Memory Usage of Sprites

So... if I put my files on resources folder I don't need to manually link them on References of the Localize? You just saved me days of work if this is true! =)


Yes, any file in the resources folder is saved as a path, so no need to reference them in the References section.

BTW, if you already have them in the references section, you will need to remove them from there once you move the sprites to the Resources folder. Otherwise, the sprites will still be referenced and always loaded.

Hope that helps!
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
Last edit: 8 years 4 months ago by Frank.

Please Log in or Create an account to join the conversation.

Time to create page: 0.163 seconds
Template by JoomlaShine