0
0
Unityframework~10 mins

Save slot management in Unity - Interactive Code Practice

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

Complete the code to declare a save slot variable.

Unity
int [1] = 1;
Drag options to blanks, or click blank then click option'
AslotNumber
BsaveIndex
CsaveSlot
DslotId
Attempts:
3 left
💡 Hint
Common Mistakes
Using vague or unrelated variable names.
Using reserved keywords.
2fill in blank
medium

Complete the code to save player data to a slot using PlayerPrefs.

Unity
PlayerPrefs.SetString("SaveSlot" + [1], playerData);
Drag options to blanks, or click blank then click option'
AslotId
BslotNumber
CsaveIndex
DsaveSlot
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable that is not defined.
Forgetting to convert the slot number to string.
3fill in blank
hard

Fix the error in the code to load data from a save slot.

Unity
string data = PlayerPrefs.GetString("SaveSlot" + [1], "");
Drag options to blanks, or click blank then click option'
AslotId
BsaveSlot
CsaveIndex
DslotNumber
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong variable name causing key mismatch.
Forgetting to provide a default value.
4fill in blank
hard

Fill both blanks to check if a save slot exists and load it.

Unity
if (PlayerPrefs.HasKey("SaveSlot" + [1])) {
    string data = PlayerPrefs.GetString("SaveSlot" + [2], "");
}
Drag options to blanks, or click blank then click option'
AslotNumber
BsaveIndex
CslotId
DsaveSlot
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variables for checking and loading.
Using undefined variables.
5fill in blank
hard

Fill all three blanks to delete a save slot and confirm its removal.

Unity
PlayerPrefs.DeleteKey("SaveSlot" + [1]);

if (!PlayerPrefs.HasKey("SaveSlot" + [2])) {
    Debug.Log("Save slot " + [3] + " deleted successfully.");
}
Drag options to blanks, or click blank then click option'
AslotNumber
BsaveIndex
CslotId
DsaveSlot
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variables causing mismatch.
Not checking if the key was deleted.