-
Notifications
You must be signed in to change notification settings - Fork 0
Player Data
Jiufen edited this page Apr 2, 2021
·
3 revisions
We are going to take a look at the player data functionality of playfab. This player data, allow us to save an string info, so we have more posibilities to save the data of the player.
Like the previous parts of the wiki, we will create a request for the player data and then we assign an onSuccess and an Onfailure callback:
public static void SetUserData() {
PlayFabClientAPI.UpdateUserData(new UpdateUserDataRequest() {
Data = new Dictionary() {
{"InventorySize", "5"},
{"Inventory0", "Sword"},
{"Inventory1", "Shield"},
{"Inventory2", "Bow"},
{"Inventory3", "Spell"},
{"Inventory4", "Potion"},
}
},
result => Debug.Log("Successfully updated user data"),
error => {
Debug.Log("Error setting player inventory");
Debug.Log(error.GenerateErrorReport());
});
GetUserData();
}If hadn't any player Data for this player we proceed to create a new one:
public static void SetUserData() {
PlayFabClientAPI.UpdateUserData(new UpdateUserDataRequest() {
Data = new Dictionary() {
{"InventorySize", "5"},
{"Inventory0", "Sword"},
{"Inventory1", "Shield"},
{"Inventory2", "Bow"},
{"Inventory3", "Spell"},
{"Inventory4", "Potion"},
}
},
result => Debug.Log("Successfully updated user data"),
error => {
Debug.Log("Error setting player inventory");
Debug.Log(error.GenerateErrorReport());
});
GetUserData();
}Home
C#
Game Design Patterns
- Command
- Flyweight pattern & Scriptable Objects
- Observer pattern
- State pattern
- Object Pool pattern
- Factory pattern
ECS
PlayFab
- Introduction
- Template Class
- Player Authentication
- Mobile Authentication
- Player Statistics
- Leaderboard
- Player Data
- Friends
Mirror