Search Issue Tracker

Won't Fix

Votes

1

Found in

2021.3.30f1

2022.3.9f1

2023.1.12f1

2023.2.0b8

2023.3.0a4

Issue ID

UUM-48261

Regression

No

"PlayerPrefs.GetString" returns an empty string when the default value is set to "null"

-

Reproduction steps:
1. Open project “PlayerPrefsRepro.zip”
2. Open “SampleScene”
3. Enter Play Mode
4. Observe the Console

Expected result: No error is thrown
Actual result: “AssertionException: Assertion failure. Values are not equal. Expected: == “ error is thrown in the console

Reproducible with: 2021.3.30f1, 2022.3.9f1, 2023.1.12f1, 2023.2.0b8, 2023.3.0a4

Reproducible on: macOS Ventura 13.2.1 (Intel), Windows 11 (by the reporter)
Not reproducible on: no other environment tested

Notes:
- Also reproducible in Standalone Player
- changing line 12 in “Repro.cs” to {{Assert.AreEqual("", PlayerPrefs.GetString("test-key", null));}} gives Expected results

  1. Resolution Note:

    This is by design. You can never get null from PlayerPrefs.GetString() API.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.