- Home /
Resources.Load doesnt' find the assets
I'm trying to load and instantiate the prefab but I can't figure out how Load works. I'm using the function like this:
GameObject prefab = (GameObject)Resources.Load("/Prefabs/fenceLow", typeof(GameObject));
My folder with prefabs looks like this:
Do you know how to use it properly? Thanks.
Answer by AlucardJay · May 05, 2014 at 10:09 AM
They must be in a master folder named Resources, eg
Assets > Resources > Prefabs
All assets that are in a folder named "Resources" anywhere in the Assets folder can be accessed via the Resources.Load functions. Loads an asset stored at path in a Resources folder. The path is relative to any Resources folder inside the Assets folder of your project.
that code will load file: Assets/Resources/Prefabs/fenceLow.prefab
yes and you can also add a public gamobject to the script and add to the ingameobject file and it should work but best to use resources because thats what the game loads on start //1st loading screen after build