[英]How do I setup rewarded ads in unity
In my android app which Im developing in unity I use admob for my advertising. 在我统一开发的android应用中,我将admob用于广告。 The banner works fine but I want to reward a player when they watch an advertise.
横幅广告效果很好,但我想奖励观看广告的玩家。 There is no solid explanation or tutorial on how to setup rewarded advertises for unity on the web that I can find.
在我可以找到的网络上,没有关于如何设置奖励广告统一的可靠解释或教程。 I setup unity ads for my mediation in admob and have almost no clue what ZoneId means.
我为admob中的中介设置了统一广告,几乎不了解ZoneId的含义。 I just entered the integration Id on unity ads which was "rewardedVideo".
我刚刚在统一广告中输入了“ rewardedVideo”的集成ID。
I then entered the ad unit id into the googleplaydemoscript in unity and ran it, when I pressed the request and show rewarded video nothing happened. 然后,我将广告单元ID统一输入到googleplaydemoscript中,然后运行它,当我按下请求并显示奖励视频时,什么也没发生。
Can someone please give me a guide on how to setup rewarded ads in unity with admob? 有人可以给我指南如何与admob一起设置奖励广告吗? Thanks.
谢谢。
Look that answer from groups google. 在Google群组中寻找答案。
https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/ZxbVL60cHFo https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/ZxbVL60cHFo
Check if your problem is correct folder for mediation setup. 检查您的问题是否是用于中介设置的正确文件夹。
First, set the build targets and enable Unity Ads in the Services Panel. 首先,设置构建目标并在服务面板中启用Unity Ads。
Edit > Build Settings
and set the platform to iOS
or Android
Edit > Build Settings
然后将平台设置为iOS
或Android
Once that's done, select Window > Services
. 完成后,选择
Window > Services
。 Select an Organization from the drop down menu: Click Create
. 从下拉菜单中选择组织:点击
Create
。
Click Ads
, and enable the SDK in your project: 点击
Ads
,然后在您的项目中启用SDK:
Add the code 添加代码
First, declare the Unity Ads namespace in the header of your script 首先,在脚本标题中声明Unity Ads命名空间
using UnityEngine.Advertisements;
Then, you can display an ad by calling the following method 然后,您可以通过调用以下方法来展示广告
Advertisement.Show();
Example Code 范例程式码
Add a button to your scene that plays an ad, then handles status and callbacks. 将一个按钮添加到播放广告的场景中,然后处理状态和回调。
Step 1: Select Game Object > UI > Button
to add a Button in your scene 步骤1:选择“
Game Object > UI > Button
以在场景中添加一个按钮
Step 2: Add the following script to the button: 步骤2:将以下脚本添加到按钮:
using UnityEngine;
using UnityEngine.Advertisements;
public class UnityAdsExample : MonoBehaviour
{
public void ShowRewardedAd()
{
if (Advertisement.IsReady("rewardedVideo"))
{
var options = new ShowOptions { resultCallback = HandleShowResult };
Advertisement.Show("rewardedVideo", options);
}
}
private void HandleShowResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
Debug.Log("The ad was successfully shown.");
//
// YOUR CODE TO REWARD THE GAMER
// Give coins etc.
break;
case ShowResult.Skipped:
Debug.Log("The ad was skipped before reaching the end.");
break;
case ShowResult.Failed:
Debug.LogError("The ad failed to be shown.");
break;
}
}
}
Then simply press the editor Play button to test the Unity Ads Button integration. 然后只需按编辑器的“播放”按钮即可测试Unity Ads Button集成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.