I have a folder of fbx models from a to z, as in a.fbx b.fbx c.fbx, and so on. I want to randomly assign a game object a mesh from this folder, what is the best way to go about this?
Drag all the Meshes into a public Mesh[ ] AllMeshes;
array, then pick randomly from that array.
1 Like
Thanks Kurt. Is there a way to automate that? I’m trying to avoid manually dragging etc
you can move all meshes into the Resources folder and then load and use them however you want https://docs.unity3d.com/ScriptReference/Resources.LoadAll.html
Some choices:
-
as @pixaware_pwedrowski notes, use Resources.LoadAll() to live load at runtime whatever is found in a directory you specify (see docs for requirements!)
-
write editor tooling to use AssetDatabase (editor time only) to find meshes you want and inject them into this list, then be sure they get saved.