Unity 遊戲中的玩家統計資料
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Player Stats API 可以根據特定玩家區隔和玩家生命週期的不同階段,打造專屬的遊戲體驗。您可以根據玩家的進度、消費和互動情形,為每個玩家區隔打造專屬的體驗。舉例來說,您可以利用此 API 主動採取行動,鼓勵較不活躍的玩家再次與遊戲互動,例如:在玩家登入時顯示和宣傳新的遊戲內商品。
回呼會採用兩個參數:
1. 結果代碼小於或等於零為成功。
請參閱 CommonStatusCodes 以瞭解所有值。1. PlayGamesLocalUser.GetStats 方法中的 PlayerStats 物件。
詳情請參閱玩家統計資料指南。
完成驗證即可使用玩家統計資料:
((PlayGamesLocalUser)Social.localUser).GetStats((rc, stats) =>
{
// -1 means cached stats, 0 is success
// see CommonStatusCodes for all values.
if (rc <= 0 && stats.HasDaysSinceLastPlayed()) {
Debug.Log("It has been " + stats.DaysSinceLastPlayed + " days");
}
});
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Player statistics in Unity games\n\nThe Player Stats API let you tailor game experiences to specific segments\nof players and different stages of the player lifecycle. You can build\ntailored experiences for each player segment based on how players are\nprogressing, spending, and engaging. For example, you can use this API to\ntake proactive actions to encourage a less active player to re-engage with\nyour game, such as by displaying and promoting new in-game items when the\nplayer signs in.\n\nThe callback takes two parameters:\n1. The result code less than or equal to zero is success.\nSee [CommonStatusCodes](https://developers.google.com/android/reference/com/google/android/gms/common/api/CommonStatusCodes) for all values.\n1. The [PlayerStats](/games/services/unity/v2/api/class/google-play-games/basic-api/player-stats)\nobject from the\n[PlayGamesLocalUser.GetStats](/games/services/unity/v2/api/class/google-play-games/play-games-local-user) method.\n\nFor more information see the\n[player stats guide](/games/services/android/stats).\n\nThe player stats are available after authenticating: \n\n ((PlayGamesLocalUser)Social.localUser).GetStats((rc, stats) =\u003e\n {\n // -1 means cached stats, 0 is success\n // see CommonStatusCodes for all values.\n if (rc \u003c= 0 && stats.HasDaysSinceLastPlayed()) {\n Debug.Log(\"It has been \" + stats.DaysSinceLastPlayed + \" days\");\n }\n });"]]