Unity Ads GMS2

Table of Contents

Setting up #

First of all, thank you so much for purchasing our extension! It means the world. This documentation will guide you how to use the asset, but if you have any questions at all, feel free to reach out at contact@bunnibyte.com. We’ll reply ASAP!

Installing The Extension #

After purchasing the extension on the Gamemaker marketplace, open the Gamemaker Studio 2 IDE in the project you want to add the extension to. Next, select “Marketplace > My Library” in the toolbar. In the search bar located in the top-left, simply search “Unity Ads GMS2” and click the download icon. Once the extension has been downloaded, select the “Import” button on the right panel. This will bring up a dialogue asking you which assets you want to import.

For the extension to work, you only need to import the extension “unity_ads”, and the object “cont_unity_ads”. The other resources are for demonstration purposes and are not needed for the extension to work. Next, drag and drop the “cont_unity_ads” object into the first room of your game.

Configuring Build Settings #

In Game Options > Android > General, we recommend the following build settings:

example image

We strongly recommend using the above build settings. Change at your own risk! (Note: The extension will not work with a “Minumum SDK” set to under 19.)

Setting Ad Unit IDs #

Now that the unity ads controller object and extension are added to your project, all we need to do before serving ads is filling in your Unity Ads details. In the “cont_unity_ads” object, go to the “Create” event. You should see a switch block that looks something like this:

// Set up IDs for different platforms
switch(os_type) {
	case os_android:
		// Set up IDs for the Android version
		var unityGameID = "xxxxxxx";
		
		global.bannerID = "Android_Banner";
		global.interstitialID = "Android_Interstitial";
		global.rewardedVideoID = "Android_Rewarded";
	break;
	case os_ios:
		// Set up IDs for the iOS version
		var unityGameID = "xxxxxxx";
		
		global.bannerID = "iOS_Banner";
		global.interstitialID = "iOS_Interstitial";
		global.rewardedVideoID = "iOS_Rewarded";
	break;
}

You need to set the variable “unityGameID” to your, well, Unity Game IDs. Go to the Unity Gaming Services Dashboard, and in the left menu, click “Monetization.” In your project, select the “Ad Units” option. You should see something like this:

example image

Simply copy-paste the Game IDs for their respective platforms into the code asking for it. Example:

example image

Do the same with the Ad Unit IDs. Once you do it, you’re all set up, wohoo! 🥳

Interstitial Ads #

Interstitial ads are video ads that play between actions, (ex. inbetween a level), and allow the player to skip (usually after five seconds). To show an interstitial ad, all you have to do is first check if the interstitial is ready to be shown, and if so, show the ad. Simple! Like this:

if(unity_ads_is_ready(global.interstitialID)) {
	// The ad unit is ready to show-- show it!
	unity_ads_show(global.interstitialID);
}

Easy as that! :)

Rewarded Ads #

Rewarded ads are the highest paying option. The user is required to watch the ad fully, and when the ad is complete, they get a reward! (Hence, the name “Rewarded Ad”). Showing a rewarded ad is similar to interstitials, simply check if the ad is ready, and if so, show it. Like this:

if(unity_ads_is_ready(global.rewardedVideoID)) {
	// The ad unit is ready to show-- show it!
	unity_ads_show(global.rewardedVideoID);
}

Once the rewarded ad has finished and the user has closed it, the function “rewarded_ad_complete” will be called. This is located in the create event of the object “cont_unity_ads”. You can simply change this to whatever you’d like to do, such as giving the user coins. Example:

// (In the create event of cont_unity_ads)
function rewarded_ad_complete() {
	// Rewarded ad successfully completed! 
	show_message_async("Thank you for watching! You get +5 clout!");
}

Showing Banners #

Banner ads are small banners (usually) located in the bottom of the screen. These ads take up the least screen real-estate, but are also the lowest paying option. You can start showing a banner ad like this:

unity_ads_banner_create(global.bannerID, true, 320, 50);

This function takes in four functions: the banner ID, whether or not it’ll be located at the bottom, and the size of the ad unit. These are all self-explanitory, but it’s important to note however that your banner ads can only be 320x50 for phones, or 728x90 for tablets.

To remove a banner ad that’s showing, simply call the destroy function:

unity_ads_banner_destroy();

Thank you! #

Once again, thank you so so much for purchasing our asset! It means the world. If you found this extension useful, leaving a review on the Marketplace would be amazing! Again, if you have any questions at all, feel absolutely free to reach out at contact@bunnibyte.com. Thank you!