> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 使用实体对象存储玩家数据

> 使用 SetObjects 和 GetObjects 在 PlayFab 实体上存储和检索小型 JSON 对象，附有玩家数据的 C# 示例和 Game Manager 审查。

实体对象允许你读取和写入附加到实体的小型 JSON 可序列化对象。所有实体类型都支持相同的 `GetObjects` 和 `SetObjects` 方法。

下面显示的示例演示了在 `title_player_account` 上设置和读取一个 `Object`。

```csharp theme={null}
var data = new Dictionary<string, object>()
{
    {"Health", 100},
    {"Mana", 10000}
};
var dataList = new List<SetObject>()
{
    new SetObject()
    {
        ObjectName = "PlayerData",
        DataObject = data
    },
    // A free-tier customer may store up to 3 objects on each entity
};
PlayFabDataAPI.SetObjects(new SetObjectsRequest()
{
    Entity = new EntityKey {Id = entityId, Type = entityType}, // Saved from GetEntityToken, or a specified key created from a titlePlayerId, CharacterId, etc
    Objects = dataList,
}, (setResult) => {
    Debug.Log(setResult.ProfileVersion);
}, OnPlayFabError);
```

```csharp theme={null}
var getRequest = new GetObjectsRequest {Entity = new EntityKey {Id = entityId, Type = entityType}};
PlayFabDataAPI.GetObjects(getRequest,
    result => { var objs = result.Objects; },
    OnPlayFabError
);
```

## Game Manager 和实体

Game Manager 允许你为玩家操作对象和文件。玩家概览已更新，可同时显示 title player 和 master player account 信息。

<img src="https://mintcdn.com/microsoft-4404708b/3hg2JQs0m7qmDqay/images/playfab/live-service-management/game-configuration/entities/tutorials/game-manager-entities-player-overview.png?fit=max&auto=format&n=3hg2JQs0m7qmDqay&q=85&s=ceac36d3b1e7fd248caeedbf4bea8055" alt="Game Manager - Entities - Player overview" width="1800" height="1406" data-path="images/playfab/live-service-management/game-configuration/entities/tutorials/game-manager-entities-player-overview.png" />

此外，文件和对象现在在 **Players** 选项卡中有其自己的部分。

<img src="https://mintcdn.com/microsoft-4404708b/3hg2JQs0m7qmDqay/images/playfab/live-service-management/game-configuration/entities/tutorials/game-manager-entities-player-files.png?fit=max&auto=format&n=3hg2JQs0m7qmDqay&q=85&s=70b96669460d8bb673ec25fdbcd1bd41" alt="Game Manager - Entities - Player Files and Objects" width="1800" height="969" data-path="images/playfab/live-service-management/game-configuration/entities/tutorials/game-manager-entities-player-files.png" />

## 相关功能

实体对象和文件在多个 PlayFab 功能中使用，每个功能都作用于不同的实体类型：

| 功能                                                                                 | 实体类型                                                         | 用例                |
| ---------------------------------------------------------------------------------- | ------------------------------------------------------------ | ----------------- |
| [Game Server 配置](/services/playfab/live-service-management/game-configuration)     | `game_server`                                                | 服务器端设置和服务器权威数据    |
| [Title 数据](/services/playfab/live-service-management/game-configuration/titledata) | `namespace`, `title`                                         | 在所有玩家之间共享的全局键/值配置 |
| [玩家数据](/services/playfab/player-progression/player-data)                           | `title_player_account`, `master_player_account`, `character` | 每位玩家的配置文件、进度和偏好存储 |
| [群组](/services/playfab/community/associations/groups)                              | `group`                                                      | 在玩家群组或公会内共享的数据    |


## Related topics

- [玩家数据](/zh-CN/services/playfab/player-progression/player-data/index.md)
- [PlayFab GDPR - 导出玩家数据](/zh-CN/services/playfab/data-analytics/privacy-compliance/gdpr-exporting-player-data.md)
- [PlayFab GDPR - 删除玩家数据](/zh-CN/services/playfab/data-analytics/privacy-compliance/gdpr-deleting-player-data.md)
- [实体文件](/zh-CN/services/playfab/live-service-management/game-configuration/entities/entity-files.md)
- [游戏服务器配置概述](/zh-CN/services/playfab/live-service-management/game-configuration/index.md)
