Separating UI from data

I’m curious to hear different approaches on how to separate UI from data, as I’m in the planning phases of a new game that requires a database to store various items. I’ll need to access various properties of these items during gameplay, as well as display them in several different menus. I want to approach optimization as a design consideration rather than an afterthought, so I thought it would be best to separate UI elements from the data.

For example, I have a Weapon class that stores values for its name, damage, durability, and health, as well as functions for inflicting damage, reducing health, and breaking. Rather than also storing their UI icons, I have a separate class that is responsible for rendering Weapon icons in the various screens. So when the menu is loaded, it initializes by checking to see what the player has in their inventory, cross-referencing a collection of icons, then populating the menu.

Does that make sense?

I would love to hear some input on this approach. Is there a better way to handle this? Specifically how could I go about doing this? Would I store ID keys in the data classes, then use those to reference the media externally?

Thanks!

P.S. I plan to be using ScriptableObjects for the individual items, which I could then pass into the UI renderer to display the appropriate information.

hey;
did u try unity “Scriptable Objects” ?

its so optimized and very fast;

u can use it to hold as much data as u need;