Since my number of scene objects has increased dramatically with procedurally generated cities, I noticed that FindObjectsOfType and similar calls became very expensive.
So I’m about to write some kind of manager/registry for keeping track of objects of certain kinds efficiently.
I’m sure people here have done this lots of times, and I wanted to get some opinions on what kinds of data structures and architectures are best for this purpose.
My most complex use case involves Combatants, which can be on different teams (an integer). These combatants frequently need to inspect all other (nearby) combatants - sometimes of the own team, sometimes of other teams.
Also, what is the most convenient approach to registering and unregistering/cleaning the tracked objects? Start() and check for nulls every update? Or something different?