PlayerPrefs.cs (DO NOT use PlayerPrefs as name of your script)

I was following the tutorial and couldn’t figure out why the PlayerPrefs.cs weren’t working or recognizing:

PlayerPrefs.SetFloat(MASTER_VOLUME_KEY, volume);

It had a red squiggly line under “PlayerPrefs”. That’s because we had the name of the PlayerPrefs.cs as our Unity C# script file. So I renamed the file to “PlayerPreferences.cs” instead of “PlayerPrefs.cs”. That solved the problem!
I just wanted to share that info in case someone else runs into this same issue.

Privacy & Terms