Gather prefabs through code

hey guys, i have a bunch of prefabs of (for this example, lets say) weapons.
so…

WeaponName
-> gameobject with mesh
-> whatever else is childed to it (attached scopes, etc!)

and all these prefabs are tagged with ‘weapon’.

is there a way to iterate through all objects with that tag and add them to a list? so that i can instantiate them later?

i know i can do this through the editor, by making a public List and putting all my weapon prefabs into that list by hang, but i want to do it through code so that i can just add weapons as i please and the game will just pick it up and add it to the list rather than me having to do it each time

The following method returns an array containing all the game objects with a particular tag.

I’d try:

Through that won’t work with prefabs … :frowning:

You could also look at Resources.

yes, i know about that function, but that only works on objects within the scene, and not on the prefabs as NPSF3000 has pointed out…this is what i need! :frowning:

i will have a look at resources now.

suppose i can use Unity - Scripting API: Resources.LoadAll and put all my weapons into a weapons folder :stuck_out_tongue: