- Home /
How to create a list of prefabs when given path in project directory
I have a bunch of modular prefabs and I want to make a custom editor script with some gizmos for myself so i can build the maps more quickly. for what i have in mind the only part that I'm clueless on is how to make an array of the prefabs I have in a folder inside my project.
Ideally id like to be able to drag a folder into a public path variable for the script and have it loop through the folder (I can implement a recursive solution later for sub folders, i just need a starting point for accessing those files really)
Answer by jmgek · Jan 12, 2017 at 09:41 PM
You need to create a resource folder in your project, to access your objects: http://answers.unity3d.com/questions/460161/how-do-i-get-a-list-of-filenames-in-a-resources-fo.html
And it also sounds like your going to want to execute In edit mode: https://docs.unity3d.com/ScriptReference/ExecuteInEditMode.html
Or do you need an actual array? GameObject[ ] gameobjects ;