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
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Terms of Service agreement checkbox is invisible under specific OS system themes (UI Accessibility)
- Tile Palette: "Create New Tilemap" dropdown area is displayed in several colors
- Input.mousePosition stops syncing to touch input when using "DownloadHandlerTexture" in WebGL build
- UI Builder canvas doesn't update element styling accordingly when changing Active Theme for some Editor Authoring elements
- Selector Value buttons are not aligned with parameters in UI Builder
Resolution Note:
This is by design. You can never get null from PlayerPrefs.GetString() API.