ドキュメント

​
​

Development

User Acquisition

Monetization

産業

Leaderboards

Unity SDK tutorial

Open Unity Dashboard

Leaderboards

LiveOps
​
​
Leaderboards
  • Overview
  • Get started
  • Concepts
  • Tutorials
    • Configuration
    • Unity SDK tutorial
    • Unity SDK sample
    • Cloud Code samples
      • Cloud Code Modules (C#)
      • Cloud Code Script (Javascript)
  • Reference
  • Privacy and consent
  1. Leaderboards

Cloud Code JavaScript スクリプトによるリーダーボードへのアクセス

Refer to code samples that access Leaderboards with the Cloud Code JavaScript Software Development Kit.
読み終わるまでの所要時間 3 分
最終更新 8ヶ月前

Cloud Code JavaScript Leaderboards SDK を使用してリーダーボードにアクセスできます。Cloud Code SDK ドキュメントポータル では、利用可能なすべてのメソッドが記載されているドキュメントを提供しています。
プレイヤーが Cloud Code スクリプトを呼び出す例について考えてみましょう。以下のスクリプトは、プレイヤーのスコアを送信し、そのエントリー (ランクなど) を取得し、さらにリーダーボードの上位スコアを取得します。
JavaScript:
const { LeaderboardsApi } = require("@unity-services/leaderboards-1.1");module.exports = async ({ params, context, logger }) => { // Retrieve the playerId and accessToken from the context // allows you to ensure requests are scoped to the player // who invoked the Cloud Code script. const { projectId, playerId, accessToken } = context; const { leaderboardId, score } = params; // Initializing the LeaderboardsApi using the accessToken // ensures the requests are made as the player who invoked the // Cloud Code script. const leaderboardsApi = new LeaderboardsApi({ accessToken}); const addScoreResult = await leaderboardsApi.addLeaderboardPlayerScore(projectId, leaderboardId, playerId, { score: score }); const getScoreResult = await leaderboardsApi.getLeaderboardPlayerScore(projectId, leaderboardId, playerId); const getScoresResult = await leaderboardsApi.getLeaderboardScores(projectId, leaderboardId); return { addScoreResultStatus: addScoreResult.status, getScoreResult: getScoreResult.data, getScoresResult: getScoresResult.data };};
プレイヤースコープのエンドポイントへの管理レベルのアクセスも Cloud Code を介して利用可能です。これにより、単一の Cloud Code スクリプトから、複数のプレイヤーのスコアや、Cloud Code スクリプトを呼び出したプレイヤー以外のプレイヤーのスコアを更新できます。
JavaScript:
const { LeaderboardsApi } = require("@unity-services/leaderboards-1.1");module.exports = async ({ params, context, logger }) => { const { projectId } = context; // The below playerId comes from your input parameters. This can // be any player that you wish. const { leaderboardId, playerId, score } = params; // Initialize the LeaderboardsApi using the context allows // for admin-level access to Leaderboards endpoints. const leaderboardsApi = new LeaderboardsApi(context); const addScoreResult = await leaderboardsApi.addLeaderboardPlayerScore(projectId, leaderboardId, playerId, { score: score }); const getScoreResult = await leaderboardsApi.getLeaderboardPlayerScore(projectId, leaderboardId, playerId); const getScoresResult = await leaderboardsApi.getLeaderboardScores(projectId, leaderboardId); return { addScoreResultStatus: addScoreResult.status, getScoreResult: getScoreResult.data, getScoresResult: getScoresResult.data };};

追加リソース

  • Unity Dashboard
  • Cloud Code ドキュメント
  • Unity Authentication

Copyright © 2026 Unity Technologies
法規事項プライバシーポリシークッキーDocumentation Terms of Use私の個人情報を販売または共有しないプライバシーに関する選択 (クッキー設定)

"Unity" の名称、Unity のロゴ、およびその他の Unity の商標は、米国およびその他の国における Unity Technologies またはその関係会社の商標または登録商標です (詳しくはこちら)。その他の名称またはブランドは該当する所有者の商標です。

一部のページは利便性向上のため機械翻訳を使用しており、内容に不正確な表現が含まれる場合があります。内容に齟齬または不一致が生じた場合は、英語版を正本とします。

  • このページ
    • 追加リソース


このページの問題を報告する