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);*
Why are you using "\\" ?
– proandriusI mean two \
– proandriusDo you get null when you do this print(obj); ?
– proandrius"\\" is kind of like an escape character, so if the compiler tries to parse it it thinks you're telling it code. To actually have a backslash in your string, one of the ways to write it is with two "\\". Edit: even this comment box can't understand a single slash haha
– tWayfarerYeah, I get null when I print it, too.
– tWayfarer