Examples
Set up a banner ad using the ‘adLoaded’ callback
This example demonstrates how to set up a banner ad with the Bumper page enabled, and display the ad as soon as it loads.
In order to run this C# script it will need to be attached to a GameObject
.
using tv.superawesome.sdk.publisher;
public class MainScript : MonoBehaviour {
private SABannerAd banner = null;
void Start () {
// Initialise the SDK (Skip this if you already initialised it elsewhere...)
AwesomeAds.init(true); // In production usages set logging parameter to false
// Create a new SuperAwesome Banner Ad
banner = SABannerAd.createInstance();
// Enable the Bumper page feature (optional)
banner.enableBumperPage();
// Will display test ads (optional)
banner.enableTestMode(); // Remove this line to use a real placement
// Add a callback
banner.setCallback((placementId, evt) => {
// When the ad loads, play it directly
if (evt == SAEvent.adLoaded) {
banner.play();
}
});
// Start the ad loading process
banner.load(11111); // Replace this with your placement ID or enable test mode instead
}
}
Set up multiple ads using the ‘HasAdAvailable’ method
This example demonstrates how to set up and display:
- a banner ad with the Parental Gate enabled.
- multiple video ads with the Bumper page enabled.
In order to run this C# script it will need to be attached to a GameObject
.
using tv.superawesome.sdk.publisher;
public class MainScript : MonoBehaviour {
private SABannerAd banner = null;
void Start () {
// Initialise the SDK (Skip this if you already initialised it elsewhere...)
AwesomeAds.init(true); // In production usages set logging parameter to false
// create a new banner
banner = SABannerAd.createInstance ();
// set up the Parental Gate on the banner ad (optional)
banner.enableParentalGate ();
// load the banner ad
banner.load (30471);
// set up some parameters on the video ad
SAVideoAd.enableBumperPage ();
SAVideoAd.disableCloseButton ();
// load the video
SAVideoAd.load (30479);
SAVideoAd.load (30480);
}
public void playBanner () {
if (banner.hasAdAvailable()) {
banner.play();
}
}
public void playVideo1 () {
if (SAVideoAd.hasAdAvailable (30479)) {
// set the orientation in which the video will play
SAVideoAd.setOrientationLandscape ();
// and play the video
SAVideoAd.play (30479);
}
}
public void playVideo2 () {
if (SAVideoAd.hasAdAvailable (30480)) {
// set the orientation in which the video will play
SAVideoAd.setOrientationAny ();
// and play the video
SAVideoAd.play (30480);
}
}
}