Salut!
How to load list of prefabs in a standalone .exe?
I have read Loop through folder of assets and put names in array - Unity Answers and I tested it with stand-alone .exe I built. The application just hangs, because there is no such folders nearby.
I mean I would like to get a list of models I’d like to output as a selection menu for a player.
So I went to Unity - Scripting API: Resources.FindObjectsOfTypeAll and coded:
void PrepareModelList()
{
Object[] listObjModels = null;
//without LoadAll standalone exe possesses only these placed in scene and inspectors.
Resources.LoadAll("", typeof(GameObject));
listObjModels = Resources.FindObjectsOfTypeAll<GameObject>();
foreach (Object curr in listObjModels)
{
Debug.Log(curr.name);
}
}
The app works fine… and the log is quite long, listing every bit of the prefab, every .fbx|.png I imported and, even more, the vast quantity of stuff from Unity3D I never knew before (like “Handless GO”, “PreRenderLight” etc). Even limiting Resources.LoadAll(“Prefabs”, typeof(GameObject)) by sub-folder I get a list of every sword and missile inside particular prefabs.
Of course I can name models with something characteristic in their name, like “Unit GD F-16 Block 60 ‘Fighting Falcon’” and “Unit Asigaru platoon” and filter necessary ones via string manipulation functions, but…
But is there a more correct and optimal method to list models a player can select for arena at run-time?
Thank you!