Hello, I’m new in mobile game development.
I want to add “Earn money” button in my game. I am using UnityAds services.
if(GUI.Button(new Rect(10,10,200,50),"EARN!")){
........PLAY REWARDED VIDEO..........
if(!skipped)
money++;
}
Can you write an example about UnityAdsVideoCompleted function?
Thanks
You can use a rewarded zone, and a callback function to do it.
Check you have "rewardedVideoZone " enabled in your dashboard.
Here i give you an example of how you can implement your code:
if(GUI.Button(new Rect(10,10,200,50),"EARN!")){
ShowAd();
}
public void ShowAd(string zone = "rewardedVideoZone "){
ShowOptions options = new ShowOptions();
options.resultCallback = AdCallbackhanler;
if (Advertisement.isReady(zone))
{
Advertisement.Show (zone,options);
}
}
void AdCallbackhanler(ShowResult result){
switch (result){
case ShowResult.Finished:
Debug.Log ("Ad Finished. Rewarding player...");
money++;
break;
case ShowResult.Skipped:
Debug.Log ("Ad Skipped");
case ShowResult.Failed:
Debug.Log("Ad failed");
break;
}
}