AdMob Reward Video for Unity
Hi guys. I am trying to set Admob Reward Video for my game. I made all the settings as they were in the examples. But I have a problem. The award must be given after watched the video, But it does not give the prize without leaves the game. I get rewarded when I enter the game again.
Here is the my codes:
private void YeniReklamAl()
{
AdRequest reklamAl = new AdRequest.Builder().Build();
VideoReklam.LoadAd(reklamAl, VideoGecisID);
}
public void ReklamGoster()
{
if (VideoReklam.IsLoaded())
{
VideoReklam.Show();
VideoReklam.OnAdRewarded += OyuncuyuOdullendir;
}
else
{
YeniReklamAl();
ReklamUP.SetActive(true);
ReklamUPAnim.Play("ReklamPGir");
}
}
private void OyuncuyuOdullendir (object sender, Reward odul)
{
int para = (int)odul.Amount;
ParaDeposuScript.para.ParaEkle(para);
}
I need your helps.
Answer by wuym67123 · Jul 15, 2017 at 02:42 AM
Download those files from Admob Unity3d Plugin Project Home https://github.com/unity-plugins/Unity-Admob or Download all the Unity admob plugin project https://github.com/unity-plugins/Unity-Admob/archive/master.zip
Installation Admob Unity
Open your project in the Unity editor. Navigate to Assets -> Import Package -> Custom Package. Select the AdmobUnityPlugin.unitypackage file. Import all of the files for the plugins by selecting Import. Make sure to check for any conflicts with files
Init Admob Unity Plugin
Create A C# script ,drag the script to a object on scene , add the follow code in the script file
using admob;
Admob.Instance().initAdmob("admob banner id", "admob interstitial id");//admob id with format ca-app-pub-279xxxxxxxx/xxxxxxxx
//Admob.Instance().initAdmob("ca-app-pub-3940256099942544/2934735716", "ca-app-pub-3940256099942544/4411468910");
Here is the minimal code to create an admob video.
Admob.Instance().loadRewardedVideo("ca-app-pub-3940256099942544/1712485313");
video need to be explicitly shown at an appropriate stopping point in your app, check that the video is ready before showing it:
if (Admob.Instance().isRewardedVideoReady()) {
Admob.Instance().showRewardedVideo();
}
Your answer
Follow this Question
Related Questions
The type or namespace name 'GameManager' could not be found 0 Answers
c# cods spaceship 0 Answers
Need Help With Arduino Code to Unity 0 Answers
How does this code work? 0 Answers