Question about a more complicated UI

In the case shown, the UI is pretty simple (just buttons), so it seems ok to destroy it and recreate it every time a unit is selected.
But what about if the UI was more complicated with character avatars, health/mana bars, weapons, actions, item quickslots, etc ?
Is there a more effective way to handle this case? Maybe each character had its own UI and enable only the selected unit’s and disable all the rest?

2 Likes

I would probably still handle that in the same way, destroy the last units objects and create the new ones.
Since this logic would only run when a unit was selected it’s not often enough to cause performance issues, just make sure you’re not creating and destroying on every single frame and it will work fine.

Keeping them all created and just disabled is also a valid approach, it’s a trade-off between memory consumption and CPU usage.

3 Likes

Thank you.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms