0
0
Unityframework~10 mins

Why persistence stores player progress in Unity - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to save the player's score using PlayerPrefs.

Unity
PlayerPrefs.SetInt("PlayerScore", [1]);
Drag options to blanks, or click blank then click option'
Ascore
Bpoints
CscoreValue
DplayerScore
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that is not defined.
Forgetting to use quotes around the key name.
2fill in blank
medium

Complete the code to load the player's score from PlayerPrefs.

Unity
int loadedScore = PlayerPrefs.[1]("PlayerScore", 0);
Drag options to blanks, or click blank then click option'
AGetInt
BSave
CSetInt
DGetString
Attempts:
3 left
💡 Hint
Common Mistakes
Using GetString instead of GetInt.
Using SetInt which saves data instead of loading.
3fill in blank
hard

Fix the error in the code to save the player's level progress.

Unity
PlayerPrefs.SetInt("PlayerLevel", [1]); PlayerPrefs.[2]();
Drag options to blanks, or click blank then click option'
ASave
BLoad
CplayerLevel
DGetInt
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same option for both blanks.
Not calling Save() after setting values.
4fill in blank
hard

Fill both blanks to check if a saved score exists and then load it.

Unity
if (PlayerPrefs.[1]("PlayerScore")) { int score = PlayerPrefs.[2]("PlayerScore"); }
Drag options to blanks, or click blank then click option'
AHasKey
BGetInt
CSetInt
DDeleteKey
Attempts:
3 left
💡 Hint
Common Mistakes
Using SetInt instead of GetInt.
Not checking if the key exists before loading.
5fill in blank
hard

Fill all three blanks to save player's name, score, and then save changes.

Unity
PlayerPrefs.[1]("PlayerName", playerName); PlayerPrefs.[2]("PlayerScore", playerScore); PlayerPrefs.[3]();
Drag options to blanks, or click blank then click option'
ASetString
BSetInt
CSave
DGetString
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up SetString and SetInt.
Forgetting to call Save().