Game: Yes2SDK.game

← Back to overview

Gameplay lifecycle signals, invite links, platform settings, and clipboard. The gameplay signals are the most important part: platforms use them to time ads and measure engagement.


Methods (Core)

SignatureDescription
gameplayStart(): voidActive gameplay started (not menus/loading).
gameplayStop(): voidActive gameplay stopped (death, pause, menu, before an ad).
happyTime(): voidSignal a positive moment (high score, level complete).
inviteLink(paramsJson: string): Promise<string>Generate an invite URL embedding params. paramsJson = JSON string of Record<string,string>. Returns the URL.
getInviteParam(key: string): stringRead a param from the launching invite link. Empty string if absent.
showInviteButton(paramsJson: string): voidShow a platform invite button.
hideInviteButton(): voidHide the platform invite button.
getSettings(): stringPlatform game settings as a JSON string.
copyToClipboard(text: string): voidCopy text to clipboard.
getServerTimeAsync(): Promise<number>Current server time as Unix epoch milliseconds. Falls back to the local Date.now() clock where there's no server-time API.

Platform support

MethodPokiGameDistributionCrazyGamesYandexYouTubeJest
gameplayStartReadyPartial¹ReadyReadyPartial²Partial¹⁰
gameplayStopReadyPartial¹ReadyReadyPartial²Partial¹⁰
happyTimeNoneNoneReadyNoneNoneNone
inviteLinkReady³NoneReadyNoneNoneNone¹¹
getInviteParamReady⁴NoneReadyNoneNoneNone¹¹
showInviteButtonNoneNoneReadyNoneNoneNone¹²
hideInviteButtonNoneNoneReadyNoneNoneNone
getSettingsNone⁵None⁵Ready⁶None⁵Ready⁷None⁵
copyToClipboardPartial⁸Partial⁸Partial⁸Partial⁸Partial⁸Partial⁸
getServerTimeAsyncPartial⁹Partial⁹Partial⁹ReadyPartial⁹Partial⁹

¹ Internal state only: GameDistribution has no platform gameplay call. ² YouTube sets an internal flag; the real lifecycle uses firstFrameReady/gameReady (driven by the SDK's startGame). ³ PokiSDK.shareableURL. ⁴ PokiSDK.getURLParam. ⁵ Returns "{}". ⁶ Reads CrazyGames disableChat/muteAudio. ⁷ Reads system.getLanguage() + isAudioEnabled(). ⁸ Uses the browser navigator.clipboard (and CrazyGames' copyToClipboard where present), not a dedicated platform API. ⁹ No server-time API: returns the local (unsynced) device clock via Date.now(). Yandex returns tamper-proof ysdk.serverTime(). ¹⁰ Jest has no gameplay start or stop signal. The calls are safe and update Yes2SDK's own gameplay state only. On Jest, loading ends with startGameAsync(), which tells Jest the game is loaded (see lifecycle and the Jest guide). ¹¹ Jest has no invite links. inviteLink only returns the game page's own URL with your params, which is not a Jest share link. getInviteParam only reads the page's own query string, which carries no Jest invite data. Jest launch data comes from session.getEntryPointData(), so use referrals to invite players. ¹² Throws FEATURE_NOT_SUPPORTED on Jest.


Unity (C#)

Yes2SDK.Yes2SDK.Game. Settings changes arrive on the static event Yes2SDKGame.OnSettingsChanged (Action<GameSettings>).

SignatureDescription
void GameplayStart() / void GameplayStop()
void HappyTime()
void InviteLinkAsync(Dictionary<string,string> parameters, Action<string> onSuccess = null, Action<Error> onError = null) / Task<string> …(CancellationToken)
string GetInviteParam(string key)
void ShowInviteButton(Dictionary<string,string> parameters = null) / void HideInviteButton()
GameSettings GetSettings()
void CopyToClipboard(string text)Editor uses GUIUtility.systemCopyBuffer.

GameSettings (struct): DisableChat, MuteAudio.


Defold (Lua)

Defold routes the gameplay-lifecycle signals through the session_* namespace (session_gameplay_start / session_gameplay_stop; see session.md). The game_* namespace covers the rest.

SignatureDescription
yes2sdk.game_happy_time()Positive-moment signal (CrazyGames uses it for ad timing).
yes2sdk.game_get_settings()JSON string of settings ("{}" if unavailable).
yes2sdk.game_copy_to_clipboard(text)
yes2sdk.game_invite_link(params_json, callback)params_json = JSON object. callback(self, success, url_or_err).
Get started