GameJolt SDK
API 整合流程
- Add Game
- Game API > API Settings > Game ID & Private Key
- User Name & Game Token
- Download and import Unity API v2
- Edit > Project Settings > Game Jolt API
- 填寫&勾選所有設定值
- 將 Plugins/GameJolt/Prefabs/GameJoltAPI 拖曳至場景
- 新增排行榜分數的範例語法片段
public void AddScore (int score) {
bool isSignedIn = GameJolt.API.Manager.Instance.CurrentUser != null;
int scoreValue = score;
string scoreText = scoreValue.ToString ();
int tableID = #####; // your score table id
string extraData = "";
if (isSignedIn) {
GameJolt.API.Scores.Add (scoreValue, scoreText, tableID, extraData, (bool success) => {
Debug.Log ("Player score added!");
});
} else {
string guestName = "Guest";
GameJolt.API.Scores.Add(scoreValue, scoreText, guestName, tableID, extraData, (bool success) => {
Debug.Log ("Guest score added!");
});
}
}