Is there any reasons instantiateprefab would return null in some rare case in my room generator script ? It was working perfectly fine with Instantiate() but since I wanted to keep the prefab connection, I swapped everything to prefabutility.instantiateprefab(). It works as before, but sometimes, the instantiateprefab would return null. I tried to find a similar case but nothing would solve my problem.
private void SpawningTheRoom()
{
if (roomManager.MaxRooms > roomManager.RoomCount && roomManager.RoomGrid[spawnerX, spawnerZ] == GridInfo.NA)
{
SeeNewRoomRequirements();
spawnedARoom = true;
if (mustHaveWestE)
{
if (mustHaveNorthE)
{
if (mustHaveEastE)
{
if (mustHaveSouthE)
{
room = PrefabUtility.InstantiatePrefab(roomEEEE.gameObject) as GameObject;
if (!room)
{
print("no ee");
}
room.transform.position = transform.position;
}
else
{
index = Random.Range(0, roomsWNEE.Length);
room = PrefabUtility.InstantiatePrefab(roomsWNEE[index].gameObject) as GameObject;
if (!room)
{
print(index);
}
room.transform.position = transform.position;
}
}
So here