如果在Service里无法打开ads就去资源管理里去下载
if (Advertisement.isSupported)
{
Advertisement.Initialize("4408751", false);
}
初始化广告
激励广告
if (Advertisement.isInitialized && Advertisement.IsReady("Rewarded_Android"))
{
var options = new ShowOptions { resultCallback = HandleShowResult };
Advertisement.Show("Rewarded_Android", options);
}
Advertisement.Show(“Rewarded_Android”, options)这里的第一个参数对应Unityads后台上的名字
private void HandleShowResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
complete = true;
GameManger.gameManger.Die = false;
GameManger.gameManger.Heatlh = 3;
GameManger.gameManger.CanMove = true;
gameObject.SetActive(false);
break;
case ShowResult.Skipped:
break;
case ShowResult.Failed:
break;
}
}
加个回调就可以看到结果了
|