PlayerPrefs.GetFloat returns wrong values in UWP build

When the program calls PlayerPrefs.GetFloat() the return value is wrong. For example, we save (with SetFloat) the number “1.47” and we get (with GetFloat) the number “1069334000”
This happens ONLY when the program starts. If during the execurtion we use SetFloat, then the GetFloat returns a correct value.
This happens only when running on UWP. Not on editor, not on Android, not on Windows, not on iOS

To reproduce:
Create a new project.
Switch to Universal Windows Platform.
Use SetFloat to save any float number.
Use GetFloat to load the saved number.
After the second excecution the returned number would be wrong

To test it I used the script below:

public class testGetFloat : MonoBehaviour
{
     public TextMeshProUGUI t;
     void Start()
     {
         float f = PlayerPrefs.GetFloat("xxx", 0.0f);
         float r = Random.Range(-0.01f, 2f);
         t.text = f.ToString("0.00") +" - "+ r.ToString("0.00");
         PlayerPrefs.SetFloat("xxx", r);
     }
 
}

This issue was also raised on this thread .

I notified the dev team, but please file a bug if you haven’t already.

1 Like

Thanks. I reported the bug.

Vote for this issue