🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Unity 2D Graphics Adding sprites to already existing sprites

Started by
1 comment, last by ddlox 3 years, 8 months ago

It can be done to generate a new sprite at runtime during the initialization of a level.

What I would like to do is this.

  • Merge a large image on a wall that consists of many separate sprites, like graffiti so that if the wall breaks the parts stay with the bricks.

I can write the code to do this even though the scale rotation and position of the bricks will not correspond to the scale of the overlay sprite and Wall sprite. Will take a few days but have written a similar code. in the past.

What I would like to know is:

  • How bad a memory consumption that would be?

My sprites by default are (1024 * 1024 * 4 (RGBA) = 4Mb)

So can I suppose, that if 50 bricks are affected I will consume 50 * 4 MB = 200 MB?

Advertisement

theoretically speaking ‘yes’;

but in practice you really want to merge them in such ways where u know what sprites are more likely to be “needing to be together", so you or your artist builds your wall with this in mind. So that when the wall breaks a part, for example, the bottom part of the wall will be buried under the top parts of the wall and this way the sprites for those bricks in the bottom parts can be removed/uncommitted/destroyed from the texture memory cache early and probably replaced by another smaller “hard-to-see-details” texture. So the bricks underneath will look like they have their original sprites when in fact these have been replaced by a smaller sprite that looks like the original.

This way, after breaking apart, the sprites of the top parts could have their 4mb and the ones at the bottom could have 2mb or less . So the worst case is when the wall is up and unbroken.

You should profile your mem usage as well for guidance. Here is a link to the profiler doc:

https://docs.unity3d.com/Manual/ProfilerMemory.html

That's it… all the best ?

This topic is closed to new replies.

Advertisement