I’m working on my UI, and running into a lot of cases where aggressively decoupled classes with very narrow scope need to instantiate a fairly wide variety of prefabs. The inventory screen, for instance, needs some way to locate the icon prefab for every single item type, but it doesn’t actually need knowledge about the item system- all it needs to do is retrieve a series of IDs and turn those into the desired prefab.
Thus far, I’ve been handling this by creating a Database singleton with a dict<int,GameObject> for every category of prefab I need to store, and giving it publicly-accessible GetPrefab methods that take an ID, and return a gameobject of the desired type.
This has the effect of coupling everything to my database, but since the database doesn’t do anything besides associate IDs with gameobjects, I don’t see any architectural issue with this- have I hit on a generally acceptable solution, or is this something that’s going to bite me in the rear end as the complexity of the codebase scales up?