Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
570 B
19
Indexable
Never
{
    [Header("Sprite To Change")]
    public SpriteRenderer playerSkin;

    [Header("Sprites to Cycle Through")]
    public List<Sprite> options = new List<Sprite>();

    private int currentOption = 0;

    void Start()
    {
        if (!PlayerPrefs.HasKey("currentOption"))
        {
            currentOption = 0;
        }

        else
        {
            Load();
        }

        playerSkin.sprite = options[currentOption];
    }

    private void Load()
    {
        currentOption = PlayerPrefs.GetInt("currentOption");
    }
}