Hi, I’m trying to create a list of sprites. I can create the list no problem but get an error saying I’m using an undefined object when I try to add to it.
Any ideas? here’s my code:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class flipBG : MonoBehaviour {
public Sprite BG1; // I added sprites in the inspector
public Sprite BG2;
public Sprite BG3;
List <Sprite> BGs;
void Start()
{
fillList();
}
void fillList()
{
BGs.Add (BG1); // error occurs here
BGs.Add (BG2);
BGs.Add (BG3);
}
}