Skip to content

Instantly share code, notes, and snippets.

@yasuyuki-kamata
Last active August 29, 2015 14:17
Show Gist options
  • Save yasuyuki-kamata/b548ca37a4c917139a06 to your computer and use it in GitHub Desktop.
Save yasuyuki-kamata/b548ca37a4c917139a06 to your computer and use it in GitHub Desktop.
UnityAds コールバックテスト for UnityScript
#pragma strict
import UnityEngine.UI;
import UnityEngine.Advertisements;
var gameID : String = "26870"; // GAME ID
var isTestMode : boolean = false; // テストモード
var zoneID : String = "rewardedVideoZone"; // ZONE ID
var text : Text; // デバッグ用のUI.Text
var options : ShowOptions; // ShowOptions一時格納用
function Awake ()
{
if (Advertisement.isSupported) {
// UnityAdsを初期化
Advertisement.Initialize(gameID, isTestMode);
// ShowOptionsを初期化しておく
options = new ShowOptions();
// resultCallbackに動画視聴完了時のアクションを登録
options.resultCallback = function (result : ShowResult) {
// この中に動画視聴完了時の処理を書く
// 変数resultはFailed, Skipped, Finishedのいずれかが来る
text.text = "Get incentives!";
};
}
}
function ShowRewardedVideo ()
{
if (Advertisement.isReady(zoneID)) {
Advertisement.Show(zoneID, options);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment