About gui textures and performance

Hello everyone, I am having a hard time researching the documentation about a specific question so I figured it would be best to ask.

I intent to make a lot of different character classes available in my single-player game. All classes have widely different abilities, and each ability have an icon to be displayed in the UI. As it is a single-player game, I only need one set of icons at a time, and I thought it would be better to not load them all at once for performance’s sake. The problem is, I cannot use go.property() and therefore resource.atlas() in gui scripts so it looks like I cannot dynamically load the right atlas just when the player chooses their classes upon character creation.

So, initially I thought about duplicating .gui files to set a new texture, but this poses a massive problem for making updates, as rearranging anything on the .gui files would imply to copy-paste it to every single class, change the texture and rename it, which can become very long when I’ll have a lot of different character classes (especially since there are multiple .gui files that need this per class).

Therefore I tried to research the documentation to see if there is, in fact, a mean to do the same thing as go.property("",resource.atlas()) in a .gui scene, or if, eventually, I was just wrong to do such thing because the impact on the performance would, in fact, be minimal if I put all of my atlases on just one .gui scene, given that a set of icons will be a 512 x 256 atlas.

TL;DR : does putting a dozen of 512 x 256 atlases on a single .gui scene and only use 1 of them is problematic in terms of performance, and if yes, is there a way to dynamically load a texture in a gui scene, or does a workaround exists?

Thank you in advance!

It will primarily be a memory issues and secondly a loading time issues. 512x256x4x4 is about 2mb per texture (uncompressed). Not that much to be honest. And still not super much if you have 10 or 12 of them.

For gui you can create textures at runtime and you could perhaps then load a grid of images and build and atlas that way. But I’d probably not work too much about it now.

2 Likes

Thank you a lot, that’s exactly what I needed to know!

I decided I will go for the easier solution, my game is not going to be very demanding in the first place so I can afford it.

As a fellow sufferer of performance anxiety, I would tell you that until you are actually facing a real performance problem, don’t worry about it.

1 Like

Ahah, thank you! We should start a support group for devs with performance anxiety :joy: