- Home /
UnityAds Rewarded Video
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
Such a broad request (esp. one that contains "please write me code") should be posted to the forums.
Answer by fedecaccia · May 04, 2015 at 11:25 AM
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;
}
}
Where can i find the zone? is this the "integration id" found in my dashboard? thanks
@cdm89 You can check the answer here: http://forum.unity3d.com/threads/zone-id.321109/
The zone IDs for your game are listed under the $$anonymous$$onetization Settings tab of your game profile.
Select your game profile from the Games page.
Select the $$anonymous$$onetization Settings tab.
Select the Show Advanced Settings button.
Observe the ID column under Ad Placements.
Thank you very much! I only see an integration ID column so it must be that. However when i test this on my iphone it lets me skip ads even though it should be a rewarded video. Any advice?