Text-heavy UI windows - hide or disable for mobile devices?

Hi all -

I was wondering if there’s a best practice in terms of handling text-heavy UI elements (for mobile devices) that the user interacts with only occasionally (think your typical store screen, which gets pulled up when needed but which remains out of sight for the better part of the game).

As far as I can tell, there are two ways to handle them (or are there more), though each has drawbacks:

  • Enable/Disable as needed - self-explanatory, really - if you don’t need it, gameObject.SetActive(false). The upside is that, presumably, it doesn’t consume any memory while deactivated and potentially allows for some - sparing - use of LateUpdate(). The downside is… good lord, the garbage! Enabling/disabling text alone inevitably generates garbage, and that’s before you even start to account for concatenation (of which there’s a lot going on, for example, when type double values such as 10,000,000 have to be converted to 10.00M for display purposes, etc).
  • Hide/Tuck it away somewhere/set scale to 0 - doesn’t disable anything, but hides it instead. The upside is that the garbage price of activating everything has to be paid only once, at the very start of the game, and animations are somewhat easier to set up. The downside is that you have to be even more careful with what you put into Update (honestly, I barely use it, and even then only on a conditional basis, so it’s not a big deal), that presumably the object sitting there still generates draw calls and hogs up memory, that you might have to throw your event listening system out of the window now that half your listeners are inactive, and, generally, that it seems to fly in the face of only keeping in memory things that you actually need.

How do you handle such things in your games? Looking forward to your feedback.

Cheers,
George

I’m very confused by what you are asking. You are talking about a text box and then you mention update and lateupdate? What are you doing in update and lateupdate with a text box that you are concerned about it?

Hi Brathnann -

Sorry for not being clearer. Imagine a gameObject with a scroll rect containing a list of scrollable shop entries, one for each item. Each entry reflects - via TextMeshPro - the name of the item being sold, its current upgrade level, how much damage it deals, and its price.

I - occasionally - use a conditional LateUpdate to refresh text values in situations where an external variable changes (for example, there is a prestige currency that affects how much damage you deal and which is added as a bonus to all items, which means whenever the the amount of prestige changes the value of all affected variables needs to be recalculated and the value of all texts updated). This way, I don’t update text every frame needlessly, but only when it’s actually needed.

Ah. I think I see. I’ve never used update or lateupdate to update text. Either an event or a simple call to another method is usually enough to handle text changes I find.

We have an app in the works that is pretty text heavy between the main text part and several entries in different dialogue boxes. Honestly, I’ve not seen an issue with simply turning on and off things. You’ll just have to decide for yourself if it’s a big deal or not if you’re really getting a lot of garbage out of it. I haven’t actually profiled this app because I haven’t noticed any performance issues yet to warrant any optimization concerns.

I would say if you aren’t seeing any issues, turn off what isn’t needed. Just my thoughts though.