Search Unity

Warning: PlayerPrefs.GetFloat broken on UWP 2021.3.8

Discussion in 'Windows' started by JariHuomo, Aug 20, 2022.

  1. JariHuomo

    JariHuomo

    Joined:
    Feb 8, 2013
    Posts:
    48
    Started getting negative reviews after latest app update and after investigating noticed similar issue than here https://answers.unity.com/questions/1916316/playerprefsgetfloat-returns-wrong-values-in-uwp-bu.html

    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.
    Screenshot 2022-08-21 001115.png
     
  2. timke

    timke

    Joined:
    Nov 30, 2017
    Posts:
    408
    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!
     
  3. Brouilles

    Brouilles

    Joined:
    Apr 14, 2019
    Posts:
    5
    I confirm, same issue here.
     
  4. CharIliad

    CharIliad

    Joined:
    Jun 26, 2015
    Posts:
    8
  5. livingtarget

    livingtarget

    Joined:
    Apr 21, 2015
    Posts:
    83
    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.
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    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.
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    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.
     
    PeachyPixels and JariHuomo like this.
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    The fix just landed to 2021.3.12f1 and 2022.1.20f1 too.
     
  9. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    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.
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    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.
     
  11. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    if you are the only person working in UWP in unity, I'm available to get hired to help fix the trillion pending issues...
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680