Skip to content

Instantly share code, notes, and snippets.

@yasuyuki-kamata
Last active August 29, 2015 14:17
Show Gist options
  • Save yasuyuki-kamata/a9a7a573f4bd14029c4b to your computer and use it in GitHub Desktop.
Save yasuyuki-kamata/a9a7a573f4bd14029c4b to your computer and use it in GitHub Desktop.
UnityAds コールバックテスト
using UnityEngine;
using UnityEngine.Advertisements;
using UnityEngine.UI;
public class ResultCallbackTest : MonoBehaviour
{
[SerializeField]
private string gameID = "26870";
[SerializeField]
private bool isTestMode = false;
[SerializeField]
private Text text;
void Awake ()
{
if (Advertisement.isSupported) {
Advertisement.Initialize(gameID, isTestMode);
}
}
public void ShowRewardedVideo ()
{
if (Advertisement.isReady()) {
// 動画再生開始 第一引数には"rewarded Video"タイプのzone IDを設定
// http://gyazo.com/4d5d3add4155d74b73bdc9f74fc34987
// 第二引数にはShowOptions型 コールバック関数を渡すことができる
Advertisement.Show("rewardedVideoZone", new ShowOptions {
resultCallback = result => {
// この中が動画視聴後に呼ばれる
// 変数resultはFailed, Skipped, Finishedのいずれかが来る
text.text = "Get incentives!";
}
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment