Warning: PlayerPrefs.GetFloat broken on UWP 2021.3.8

Started getting negative reviews after latest app update and after investigating noticed similar issue than here PlayerPrefs.GetFloat returns wrong values in UWP build - Questions & Answers - Unity Discussions

Tested it with the following code:

if (PlayerPrefs.GetString(“testA”) == “”)
{
PlayerPrefs.SetString(“testA”, “testA”);
}
else
{
testa.text = PlayerPrefs.GetString(“testA”);
}

if (PlayerPrefs.GetFloat(“testB”) == 0)
{
PlayerPrefs.SetFloat(“testB”, 0.2f);
}
else
{
testb.text = PlayerPrefs.GetFloat(“testB”).ToString();
}

if (PlayerPrefs.GetInt(“testC”) == 0)
{
PlayerPrefs.SetInt(“testC”, 1);
}
else
{
testc.text = PlayerPrefs.GetInt(“testC”).ToString();
}

On editor this problem does not exist, only on UWP build.

Hey,

Can you please file a bug for this issue? I don’t think this is a known problem, although I’ll ping the OS team to see if they know something.

Thank you for reporting this!

I confirm, same issue here.

Vote for this issue

2 Likes

Thanks for reporting.

We’ve just opted to add a workaround and use Get/SetInt() instead for the windows platform while awaiting a fix. Not ideal, but then again the fix won’t land for at least another month for Unity 2020 LTS. The irony is that we stored volume , so it caused major distortion reading the values back. Fun bug.

Sorry about this. I’m trying to get the fix in as soon as possible. Good news is that they get corrupted when they’re being loaded, so the data on disk isn’t actually bad and when the fix arrives, old data will load just fine.

The fix has already landed to 2023.1.0a13, 2022.2.0b10 and 2020.3.41f1, with 2021.3 and 2022.1 backports coming in hot.

2 Likes

The fix just landed to 2021.3.12f1 and 2022.1.20f1 too.

finally! what took you so long guys? This broke tons of stuff in my UWP and I had to always roll back the unity version to compile. Not to mention the time wasted until I figured out what was going because it was working perfect in previous versions.

I was on vacation practically whole second half of August and first two weeks of September and didn’t see this post until I came back.

if you are the only person working in UWP in unity, I’m available to get hired to help fix the trillion pending issues…

I am not the only one, but we are hiring!

https://careers.unity.com/position/senior-software-engineer-microsoft/4514244
https://careers.unity.com/position/senior-software-engineer-microsoft/4514237
https://careers.unity.com/position/software-engineer-microsoft-platforms/4514228