Another Way To Find Stuff In Unity

Tags in Unity are really useful. All you need is to filter through your list of game objects by their tags and you can find out a useful piece of information about an object. You can kind of use tags however you want for some kind of categorization, but the problem is, each game object only supports one. You can get around this by creating child-parent relationships and assigning different tags at different levels to create subcategories, but this can quickly become messy. Fortunately Unity has another way to look up game objects, and that is directly by Type.

One useful way to use Types

Sadly this particular use case isn’t very efficient, but no method of iterating over every object in your scene is. More ideally we should be keeping a list of objects as they are created and destroyed rather than taking this kind of snapshot, but if your architecture doesn’t allow it, this can be a stopgap, or at least a useful debugging tool.

So, if you are already using tags for something specific, but still need a way to sort through a list of game objects, type can be a potential way to work around the lack of multiple tags per game object, without resorting to more extreme measures.

Game developer with over 12 years of experience, mainly focused on MMOs.