Integrate our light weight SDK into your Unity 3D application!

Download Unity Plugin

Supported platforms:

  • Android
  • iOS

The plugin features include:

  • Support for Banner Ads
  • Support for Interstitial Ads
  • Support for Rewarded Video Ads
  • Banner positions (top/bottom)

The plugin contains a .unitypackage file to support easy import of the plugin.

Requirements

  • Unity IDE 5
  • Zone id (click here to create one).
  • Adcash Unity plugin.
  • To deploy on Android:
    • Android SDK
    • Deployment target of Android API 9 or higher
  • To deploy on iOS:
    • Xcode 5.1 or higher
    • Deployment target of iOS 7.0 or higher

Integrate the Plugin

Import Adcash package

Android Specific Setup
If your project already contains a AndroidManifest.xml file in the Assets/Plugins/Android folder, then there is no need to import it in the next step, just make this changes:
1. Add the following `uses-permission` tags:
* INTERNET – required to allow the Adcash SDK to make ad requests.
* ACCESS_NETWORK_STATE – used to check the Network connection availability.

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

2. Add AdcashActivity for full screen ads to work (interstitial and rewarded video)

        <activity
            android:name="com.adcash.mobileads.ui.AdcashActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" 
            android:theme="@style/AdcashTheme"
            android:hardwareAccelerated="true" /> 
    
  1. Open your project in the Unity editor.
  2. Navigate to Assets > Import Package > Custom Package…
  3. Select the .unitypackage file.
  4. Import all of the files for the plugins by selecting Import.
  5. Make sure to check for any conflicts with files.

Adcash SDK Unity API

The remainder of this guide assumes you are now attempting to write your own code to integrate the Adcash SDK into your game.

Banner

Here is a snippet showing how to create a banner:

using AdcashSDK.Api;
...
// Create a banner at the top of the screen.
BannerView bannerView = new BannerView("YOUR_ZONE_ID", AdPosition.Top);
// Load the banner with the request.
bannerView.LoadAd();
// Don't forget to call bannerView.Destroy() when you don't need bannerView any more.
More detailed description
The `AdPosition` enum specifies where to place the banner. The following constants are the possible ad positions:

* `AdPosition.Top`
* `AdPosition.Bottom`

The banner lifecycle is fairly straightforward:

* To load a banner:

	bannerView.LoadAd();
	

* By default, banners are visible. To temporarily hide a banner:

    bannerView.Hide();
    

* To show it again:

    bannerView.Show();
    

* When you are finished with a banner make sure to destroy it before dropping your reference to it. This lets the plugin know you no longer need the object and can do any necessary cleanup on your behalf:

    bannerView.Destroy();
    

Interstitial

The following is a snippet to create an interstitial:

using AdcashSDK.Api;
...
// Initialize an Interstitial.
Interstitial interstitial = new Interstitial("MY_AD_UNIT_ID"); 
   
// Load the interstitial with the request.
interstitial.LoadAd();

Unlike banners, the interstitials need to be explicitly shown. At an appropriate point in your app you should check that the interstitial is ready before showing it:

if (interstitial.IsLoaded()) {
    interstitial.Show();
}

Similar to banners, the interstitials also have a destroy method:

interstitial.Destroy();

Rewarded Video

The following is a snippet to create a rewarded video:

using AdcashSDK.Api;
...
// Initialize and load a Rewarded Video.
RewardedVideo rewardedVideo = new RewardedVideo ("MY_AD_UNIT_ID"); 
rewardedVideo.AdLoaded += HandleVideoLoaded;
rewardedVideo.AdReward += HandleVideoRewarded;
rewardedVideo.LoadAd();

To play video just after loading completed as well as to give reward;

public void HandleVideoLoaded (object sender, EventArgs args){
    rewardedVideo.Show();
}

public void HandleVideoRewarded (object sender, AdRewardEventArgs args){
    // Give user reward here
}

Ad Events

BannerView, Interstitial and RewardedVideo classes contain the same ad events that you can register for. These events are of type EventHandler.
Here is an example of how to register ad events on a banner:

using AdcashSDK.Api;
...

BannerView bannerView = new BannerView("YOUR_ZONE_ID", AdPosition.Top);
bannerView.LoadAd();

// Called when an ad request has successfully loaded.
bannerView.AdLoaded += HandleAdLoaded;
// Called when an ad request failed to load.
bannerView.AdFailedToLoad += HandleAdFailedToLoad;
// Called when an ad is clicked.
bannerView.AdOpened += HandleAdOpened;
// Called when the user returned from the app after an ad click.
bannerView.AdClosed += HandleAdClosed;
// Called when the ad click caused the user to leave the application.
bannerView.AdLeftApplication += HandleAdLeftApplication;
...

public void HandleAdLoaded(object sender, EventArgs args) {
    print("HandleAdLoaded event received.");
    // Handle the ad loaded event.
}

There are two special events that are with arguments.
First is AdFailedToLoad. It passes an instance of AdFailedToLoadEventArgs with a Message describing the error:

public void HandleAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) {
  print("Ad failed to load: " + args.Message);
  // Handle the ad failed to load event.
};

Second is AdReward event. This event is only for RewardedVideo ad type and it contains reward information if it was specified in publisher panel:

public void HandleVideoReward(object sender, AdRewardEventArgs args) {
    print("You received " + args.Amount + " " + args.Name);
    // Handle rewarding your user.
};

You only have to register for the events you need to use.

Support

If you need any support or assistance you can contact us by sending email to mobile@adcash.com.