Level select broken


Author: Aaronn Solomon

11/8/2023


The Problem

I was confident that my work on the level select menu was solid, but I was proven wrong. I wanted a way to lock out players from selecting levels that they hadn't already been in. But for some strange reason, the list of unlocked levels was reset each time a new scene was loaded.


The Solution

What I did was create a class that doesn't get destroyed when loading a scene. I attached that class to an empty object and tested the code and sure enough it didn't go away when I loaded scenes. From there, I put the list of unlocked levels in that new class and now the list is constant across all scenes.