Problem with clearing list
Hello, I have a problem with clearing the list of integers:
public class gameHandler : MonoBehaviour
{
public List<int> activeLevels = new List<int> {};
public int currentScene;
void Update()
{
currentScene = SceneManager.GetActiveScene().buildIndex;
if (!activeLevels.Contains(currentScene))
{
activeLevels.Add(currentScene);
}
}
public void ResetProgress()
{
Debug.Log("reset");
activeLevels.Clear();
}
}
ResetProgress() method is called from button, it does print a log in console when pressed, but it does not clear the list. I have also tried:
public void ResetProgress()
{
foreach (int lvl in activeLevels)
{
activeLevels.Remove(lvl);
}
}
but it does not work either. I would be really grateful for any help.
Comment