Unofficial API client for unityroom
Warning
このリポジトリはアーカイブされました。代わりにunityroom-sdkを利用してください。
Unityroom APIは、UnityからunityroomのAPIを利用するためのライブラリです。このリポジトリはunityroom-client-libraryのForkであり、よりシンプルで扱いやすいC# APIの提供を目標としています。
- Unity 2020.3(LTS)以上
- Window > Package ManagerからPackage Managerを開く
- 「+」ボタン > Add package from git URL
- 以下のURLを入力し、Addを押す
https://github.com/AnnulusGames/unityroom-api.git?path=Assets/Unityroom
あるいはPackages/manifest.jsonを開き、dependenciesブロックに以下を追記
{
"dependencies": {
"com.annulusgames.unityroom-api": "https://github.com/AnnulusGames/unityroom-api.git?path=Assets/Unityroom"
}
}
- こちらの手順に従い、unityroomでの準備を行う
- APIキー画面にてHMAC認証用キーをコピー
- Project Settings > Unityroomを開き、Create Settings Assetを押して設定ファイルを作成
- HMAC Keyにunityroom側で取得したHMAC認証用キーを入力
UnityroomAPI.ReportScore()からスコアの送信が可能です。
using UnityEngine;
using Unityroom; // C# Scriptの冒頭にusingを追記
// スコアを送信する
UnityroomAPI.ReportScore(1, 123.45f);
// コールバックを設定することも可能
UnityroomAPI.ReportScore(1, 123.45f, (isSuccess) =>
{
if (isSuccess)
{
// 成功時の処理
Debug.Log("Success");
}
else
{
// 失敗時の処理
Debug.Log("Failed");
}
});Create Settings Assetで作成したUnityroomSettings.assetファイルを移動させる場合、必ずResourcesフォルダ内に含めるようにしてください。