If I have the following List
that gets instantiated on Start()
:
private List<KeyValuePair<string, Texture2D>> _items;
void Start() {
_items = new List<KeyValuePair<string, Texture2D>> ();
}
When I collect items in the game like so:
public void AddItem (string name, Texture2D texture)
{
_items.Add (new KeyValuePair<string, Texture2D> (name, texture));
}
Every time I make a code change when debugging I get an error because _items
is null
because it needs to be instantiated again.
Is there anything I can do to remember the state of the list if I make code changes during debug/runtime?