Skip to content

Instantly share code, notes, and snippets.

@phoenleo
Last active January 15, 2016 05:55
Show Gist options
  • Select an option

  • Save phoenleo/7d05ec32d0e975e5c52e to your computer and use it in GitHub Desktop.

Select an option

Save phoenleo/7d05ec32d0e975e5c52e to your computer and use it in GitHub Desktop.
KadoSaku Unity Documentation

KadoSaku Unity SDK

Getting Started

This documentation will help you integrating KadoSaku Services in your game using KadoSaku SDK.
Please refer to examples for implementation.
This SDK must be installed using Touchten Framework Wizard and have dependencies to

  • TT-Core (Shared Settings & Initialization)
  • TT-Social (TTSociaExtension)
  • TT-Analytics (DataExtension)
  • KadoSaku-WebClient

Notes Don't init this module manually, unless you know what you are doing.
All initialization sequence is handled by TT-Core

Don't forget to setup your KadoSaku Settings in Unity Menu
Unity Menu Bar > KadoSaku > Edit Core Settings

  • Game App Id: get from portal.touchten.com
  • Game App Secret: get from portal.touchten.com
  • Game Public Key: get from portal.touchten.com
  • Game Name: fill with your game name
  • Game Photo Link: fill with URL to download your game icon
  • Game Link: fill with download link of your game
  • iTunes App Id: get from itunesconnect
  • Enable Auto Login: Set this to true if your game is using auto-login features
  • Enable KadoSaku Debug Message: Enable this to report KadoSaku system to console

Table of Content

Examples
Result Object Interface
Api List
Changelog


Method Usage Examples

Add namespace

using KadoSaku.Api;

Using Callback Method

void TriggerAchievement (string achievementId) {
	KS.Achievement.TriggerAchievement(achievementId, onAchievementTriggered);
}

// Create method that satisfy KadoSakuDelegate
void onAchievementTriggered (IActionResult result) {
	Debug.Log (result.IsSuccess);
	if(result.IsSuccess) {
		// TODO: Add your code here ...
	}
}

Notes on creating method that satisfy KadoSakuDelegate

  • Create void method that has one parameter that equal with KadoSakuDelegate Generic Type
  • Maybe it is easier to explain in this:
create void CallbackMethodName (T result) where T equals T in KadoSakuDelegate<T>

case 1:
void OnSubmitScoreCompleted(IActionResult result) {} => because the callback KadoSakuDelegate<IActionResult> signature
CallbackMethodName: OnSubmitScoreCompleted
T: IActionResult

case 2:
void OnLeaderboardInfoRequestCompleted (ILeaderboardInfoResult result) {} => because the callback use KadoSakuDelegate<ILeaderboardInfoResult> signature
CallbackMethodName: OnLeaderboardInfoCompleted
T: ILeaderboardInfoResult

Using Anonymous Callback Method

string achievementId = "000000000000001";
KS.Achievement.TriggerAchievement (achievementId, delegate(IActionResult result) {
	Debug.Log(result.IsSuccess);
	if (result.IsSuccess) {
		// TODO: Add your code here ...
   }
});

Notes usually the signature is provided by IDE's intellisense

Using anonymous callback method, checking result using Error and Cancelled property from IResult

string leaderboardId = "000000000000001";
KS.Leaderboard.GetLeaderboardInfo (leaderboardId, delegate(ILeadeboardInfoResult result) {
	if (result.Error != null || result.Cancelled == false) {
		Debug.LogError(result.Error.Message);
      	return;
   	}
   	// TODO: Add your code here ...
   	Debug.Log(result.Name);
});

Handle Error and Cancelled property from IResult

string leaderboardId = "000000000000001";
KS.Leaderboard.GetLeaderboardInfo (leaderboardId, delegate(ILeadeboardInfoResult result) {
	if (result.Error != null) {
		// TODO: Handle error here
		Debug.LogError(result.Error.Message);
		return; // Don't forget to return to stop program execution
	}

	if (result.Cancelled == false) {

		// TODO: Handle cancelled here
		return;
   	}

	// If there is no Error and not cancelled
   	// TODO: Add your code here ...
   	Debug.Log(result.Name);
});

Result Interface

Generic

IError
Field:

int Code
string Message

IResult
Field:

IError Error
bool? Cancelled
string RawResult

IActionResult : IResult
Field:

bool IsSuccess

Download

IDownloadMetaDataResult : IResult
Field:

DateTime? Date
int FileLength
string FileType
DateTime? LastCreated
DateTime? LastModified

IDownloadSaveResult : IResult
Field:

DateTime? Date
int FileLength
string FileType
DateTime? LastCreated
DateTime? LastModified

Leaderboard

ILeaderboardScoresResult : IResult
Field:

string Name
string Status
bool EnableMatchmaking

ILeaderboardScoresResult : IResult
Field:

IList<ILeaderboardScoreModel> Scores

ILeaderboardScoreModel
Field:

IPlayerModel Player
int Score

Player

IPlayerProfileResult : IResult, IPlayerProfileModel
Field:

IList<ILeaderboardScoreModel> Scores

IPlayerProfileModel : IPlayerModel
Field:

IPlayerModel Player
string Email
int Credits

IPlayerModel
Field:

string ObjectId
string Name
string PhotoURL

Mail

IMailResult : IResult
Field:

IList<IMailModel> Mails

IMailModel
Field:

string Id
string Title
string CustomData
string Status
string Description
DateTime SendDate
DateTime Expiration
string Type

ILoginResult : IResult
Field:

string MembershipToken
IPlayerProfileModel PlayerProfile

ITimeResult : IResult
Field:

DateTime? UTCTime

KadoSaku Api List

Properties

bool KS.IsLogin { get; }
bool KS.IsKadoSakuViewShown { get; }
bool KS.IsInitComplete { get; }
IPlayerProfileModel KS.PlayerProfile { get; }

Events

KS.onViewStateChangedEvent

Achievements

void KS.Achievement.TriggerAchievement(string achievementId, KadoSakuDelegate<IActionResult> callback)
void KS.Achievement.ShowAchievementListView()
void KS.Achievement.ShowAchievementResultView()

Authentication

void KS.Authentication.ShowLoginView(KadoSakuDelegate<IActionResult> callback)
void KS.Authentication.Logout(KadoSakuDelegate<IActionResult> callback)
void KS.Authentication.UnlinkSocialAndLogout(KadoSakuDelegate<IActionResult> callback)

CloudSave

void KS.CloudSave.UploadSave(string fileName, string file, KadoSakuDelegate<IActionResult> callback)
void KS.CloudSave.DownloadSave(string fileName, KadoSakuDelegate<IDownloadSaveResult> callback)
void KS.CloudSave.DownloadMetaData(string fileName, KadoSakuDelegate<IDownloadMetaDataResult> callback)
void KS.CloudSave.DeleteSave(string fileName, KadoSakuDelegate<IActionResult> callback)

Leaderboard

void KS.Leaderboard.ShowView(string leaderboardId)
void KS.Leaderboard.SubmitScore(string leaderboardId, int score, KadoSakuDelegate<IDownloadSaveResult> callback)
void KS.Leaderboard.GetLeaderboardInfo(string leaderboardId, KadoSakuDelegate<ILeadeboardInfoResult> callback)
void KS.Leaderboard.GetGlobalScores(string leaderboardId, LeaderboardTimeFrame timeFrame, KadoSakuDelegate<ILeaderboardScoresResult> callback)
void KS.Leaderboard.GetSocialScores(string leaderboardId, LeaderboardTimeFrame timeFrame, KadoSakuDelegate<ILeaderboardScoresResult> callback)

Mail

void KS.Mail.CheckInbox(KadoSakuDelegate<IMailResult> callback)
void KS.Mail.CheckAnnouncements(KadoSakuDelegate<IMailResult> callback)
void KS.Mail.MarkMailAsRead(string mailId, KadoSakuDelegate<IActionResult> callback)

Reward

void KS.Reward.ShowView()

User

void KS.User.UpdatePlayerProfile(KadoSakuDelegate<IPlayerProfileResult> callback)

Utility

void KS.Utility.UpdatePlayerProfile(KadoSakuDelegate<ITimeResult> callback)

Changelog

version 1.4.1

  • Fix localization bug: Cannot Update Localization by changing device's language

version 1.3.1

  • Fix KadoSaku iOS encryption library is not loaded

version 1.3.0

  • Fix Keyboard blocking Webview's input field
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment