Store all prefabs within an assets folder in an array?

Can it be done, or are there alternatives? UnityScript preferable.

Try using Resources.LoadAll

Put your prefabs in Assets/Resources/Prefabs/.

This will find all the game objects in your Prefabs folder, and print the amount of them in the console.

#pragma strict

var prefabs : Object[];

function Start()
    prefabs = Resources.LoadAll("Prefabs", GameObject);

Yes, it can be done.

First, use AssetDatabase.LoadAllAssetsAtPath() to load all assets in a folder:

Then, for each asset, call PrefabUtility.GetPrefabType():

If the return value is not PrefabType.None, then it’s a prefab, so you can add it to an array.

Look through the PrefabType return values in the link above. You may want to include/exclude other return values based on your needs.

You could discover all assets in a given folder using AssetDatabase.GetAllAssetPaths () and filter the returned path list.


string[] assetsPaths = AssetDatabase.GetAllAssetPaths ();
foreach (string assetPath in assetsPaths) {
    if (assetPath.Contains (yourPrefabsFolderPath)) {

For each filtered path you could load the prefab with Resources.LoadAssetAtPath() and store it in an array.