Hey guys, got a question.
If your not proficient I c# coding and are on a tight budget, how do you get ads in your game? I’ve tried following unity steps for ads but the ads won’t load, admit didn’t work either. It’s halting my progress and frustrating me, what’s the best course of action?
Well, Unity has a very good example of how to get Ads in the game if you’re doing video ads. But perhaps you should post what you have tried and reference the example you tried to follow. Let us know a little of how you expect it to work (are you displaying ads from button clicks or just at set intervals) and then let us know what isn’t happening.
Your best course is to get it working yourself with some help from the forums if you get stuck.
Thanks, I used this code
using UnityEngine;
using UnityEngine.Advertisements;
public class AdsUnity : 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;
}
}
}
And Thank God it finally worked.
I was just curious
How do you get:
- Allow the player to see a panel that pops up after they lost last life that gives them chance to get 1up if they watch ad?
- Make Panel disappear after 7 secs and show a countdown timer of 7 seconds?
- Allow Game Over Panel to Appear if they don’t choose yes, or if they choose no
- Allow the player to only get chance to use 1 up panel to get extra life if they watch ad once and not everytime they lose their last life? However which is better in your opinion. Ads that give extra life EVERY time playerlife < 0 or once per game?
- To reward player using video ads, like if player watched video: score++, lifecount++, etc.
- Can I see an actual video AD using this code or does the actual unity ad only show when game is published
Unfortunately, that’s a lot of questions, so actual code, I’m not going to be able to have time to give you much examples.
- Create the panel, when out of lives, pause the game and display the panel.
- Use a coroutine. You can display the countdown timer through it and of course, handle the timer itself.
- Once timer is done or they hit no(if they hit no, cancel the coroutine as well) then have another panel that pops up.
- Just track if they did it once already. A bool in one of your scripts should work fine. If they watch the ad, set it to true and then check the bool when they die to see if it’s true to determine if you should display the ad option. (once is probably good)
- You already have the code to handle when an ad finishes, now just add your reward code to trigger when it does.
- Right now you’re probably set up for testing. You will have to turn off testing when you build out the final version. In the editor, it just displays a popup but will still trigger like the video finished. Note that it is again Unity’s rules to play real videos for yourself to try and generate impressions or installs. (in other words, keep it in test mode till you deploy)