- Home /
Finding Assets/Prefabs That Are Not In The Scene
Hey,
I have a list of modular GameObjects that I want the user to user to be able to select from and various scripts to spawn. Currently I have it set up so every GameObject is assigned to a variable in the inspector. This results is a large and painful list of variables under the script.
Is there is a way of searching through all your assets for a specific tag and then searching through that list/array for something even more specific, like the Name of the object?
This would save me a lot of time, and make everything more future proof. There must be some sort of trick for searching though a group of assets that are not in the scene, rather than assigning them all individually in the inspector.
Also answers in Javascript would be preferred :) Many thanks,
Magnus
Answer by whydoidoit · Oct 05, 2013 at 01:46 PM
Well no not really :( The only other way is to include them in a Resources folder and then get them from there. However, there is no way of enumerating the contents of a Resources folder.
What I do is create a script that acts as scene resources which I can search on by name. This is basically a big array and I assign all of the relevant prefabs to it - which is at least just a big drag and drop operation rather than finding everything and assigning it individually.
Ahh lame, well it's nice to know a definitive answer.
Yeah, that is a good idea. I was thinking of something similar but was reluctant to continue assigning things in the inspector. The reason is weird actually, I was using your Save Game $$anonymous$$anager asset (which is sweet btw) and I messed up and somehow endup with ALL my previously assigned variables being unassigned, which was a massive ball-ache to reassign them all. I just don't want that to happen again as I still cant get that thing the work propperly :P
Well quite - it can be a real pain when things like that happen (sorry if it was my fault!)
It's actually useful to have things assigned per scene if you ever end up using Asset Bundles as Resources folders just bloat your distributable.
Nah dont worry, definately my fault.
Is it cool if I ask you some questions about Unity Serializer at some point in the future, when I get around to trying to implement it again?
I was trying to make simple Save/Load and Undo/Redo feature for my ship builder scene. Just I tried for days to get it to be stable enough to use, but couldn't for some reason :P
Your answer
Follow this Question
Related Questions
"GameObject.Find();" not working 2 Answers
Find Transform in the scene 2 Answers
Simple In game search field 2 Answers
Separate objects from GameObject[] group 0 Answers