locked levels for horror game's'

i am working on a horror game and i need a script that when i go to the continue canvas only one of the levels is available to play, until you progress through the story more, another level in the continue canvas becomes unlocked.

for example, i can only play on level 1 until i entered level 2, and so on and so forth.

@username

using UnityEngine;
using UnityEngine.UI;

public class LevelUnlocking : MonoBehaviour
{
    [SerializeField] private GameObject[] _levelButtons;
    private int _levelsUnlocked;
    [SerializeField] private GameObject[] _locks;
    // Use this for initialization
    private void Start()
    {
        _levelsUnlocked = PlayerPrefs.GetInt("UnlockedLevels");
        if (_levelsUnlocked == 0)
        {
            _levelsUnlocked = 1;
            PlayerPrefs.SetInt("UnlockedLevels", _levelsUnlocked);
        }

        LockRemove(_levelsUnlocked);
        MaxLevelToUnlock(10);
    }
    /// <summary>
    /// Lock Image Remove To Show That Level is unlock
    /// </summary>
    /// <param name="unlockedLevels"></param>
    private void LockRemove(int unlockedLevels)
    {
        for (var i = 0; i < unlockedLevels; i++)
        {
            if (i < unlockedLevels)
            {
                _locks*.SetActive(false);*

}
}
}
///


/// Maximun Level Of Your Game.
///

/// Total Level
private void MaxLevelToUnlock(int maxLevels)
{
for (var j = 0; j < maxLevels; j++)
{
_levelButtons[j].GetComponent().enabled = j < _levelsUnlocked;
}
}
}