For some reason I am having a hard time deleting my PlayerPref keys with a public void for a button click function. So that when Main Menu is clicked in the game, the timer keys and score keys delete and then reset by deleting. I have tried it within the timer and score script and in a separate script which I will show. I thought it was as simple as PlayerPrefs.DeleteKey(“keyName”) or PlayerPrefs.DeleteAll() but that is not working for me.
here is the part from the score script.
public void ReturnToMenu()
{
SceneManager.LoadScene(1);
PlayerPrefs.DeleteKey("scoreKey");
}
Here is the exert from the timer script.
public void DeleteTimeKey()
{
PlayerPrefs.DeleteKey("timeValue");
}
and here is the delete all key script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DeleteAllPPkeys : MonoBehaviour
{
public static void DeleteAllPPKeys()
{
PlayerPrefs.DeleteAll();
}
public void DeleteAllKeys()
{
PlayerPrefs.DeleteAll();
}
}
Any help is greatly appreciated. I have gotten the keys to delete on application quit, and you would think that it is just as simple as that but with a public void or static void in the case of a delete all key command. But, that is not working for me so far.