Random Tiled Background Error

I have been struggling with this the past few days not sure what i am doing wrong. I am new to unity so if anyone could help explaing why i am getting these errors the solution and awareness so i can improve and avoid this situation again. I am trying to get three backgounds that are made to populate randomly together. I will list images and code.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public class RandomFromList : MonoBehaviour
{

public List roomList;

void Start()
{
GenerateRoom();
}

void GenerateRoom()
{
roomList = Resources.LoadAll(“Background”).ToList();

GameObject roomToBuild = roomList[Random.Range(0, roomList.Count)];
GameObject newRoom = Instantiate(roomToBuild, transform.position, Quaternion.identity) as GameObject;
}
}


Use code tags when posting code, please.

Well firstly, it looks like your BackgroundRandomizer doesn’t exist. Your class is called RandomFromList. It should be the same as the name of the file in the editor.

Those are also textures, not GameObjects. If you want to use Instantiate you should be passing it prefabs. I’m assuming you want these on quads/planes in world space, so click on GameObject from the top left menu and create a quad for each different background. Drag them into the Background folder.

It might be better to just have a global variable containing a List of background prefabs, which you can just drag into it in the inspector:

public List<GameObject> backgroundPrefabs;

Then you can select them using your current method, saves having to use Resources.Load.