Loading prefabs into a list

I keep getting a null reference exception on the last line. I’m fairly sure the paths are all correct (and I’ve tried many different variations of the path in the actual Resources.Load command), the files are actually there in the right spot, but it doesn’t work. (prefabTypes and levelType are both strings)

DirectoryInfo dir = new DirectoryInfo("Assets\\Resources\\" + levelType);
FileInfo[] info = dir.GetFiles(prefabTypes _+ "*.prefab");_

List newList = new List();
for(int j = 0; j < info.Length; j++)

  • print(levelType + “\” + info[j].Name);*
  • GameObject obj = null;*
  • obj = Resources.Load(levelType + “\” + info[j].Name) as GameObject;*
  • print(obj);*
  • newList.Add(obj);*
    prefabs.Add(prefabTypes*, newList);*

Ok so the problem is that Resources.Load loads from Assets/Resources folder, you can’t load from C:/…etc. For example if you want to load AssetsResourcesForestStart1.prefab, you just write Resources.Load(“AssetsResourcesForestStart1”); without path and extension.

Use Resources.Load(Path.GetFileNameWithoutExtension(info[j].Name));