I am using Unity 5.5 and am getting the error ‘PlayerPrefs’ does not contain a definition for ‘SetFloat’. My code is as follows:
public static void SetMasterVolume (float volume)
{
if (volume > 0f && volume < 1f) {
PlayerPrefs.SetFloat(MASTER_VOLUME_KEY, volume);
} else {
Debug.LogError (“Master volume out of range”);
}
}
public static float GetMasterVolume () {
return PlayerPrefs.GetFloat (MASTER_VOLUME_KEY);
}
Thank you for your reply. I went back over the script and realized that I had changed the script name in the very beginning from “PlayerPrefs” to “PlayerPrefsManager”. In doing so I inadvertently had a class name of “PlayerPrefs” and my script name was “PlayerPrefsManager”. I fixed it and now the problem is solved. I have to say I feel a bit silly making such a simple mistake but I guess it’s all part of the learning process. Thanks again for the reply.
I did that too - I created the script as “PlayerPrefs” but then heard Ben give the reasoning and changed it to “PlayerPrefsManager,” but the script didn’t update the class name along with the script name.