Knowledge base

Update 1.5 -> 2.x

Contents:


Update a Unity Project

  • Unity 5.5+ includes the latest Unity ads version

  • Unity 5.4 and older must use the Asset Package to update

Asset Package Integration

The Unity.Advertisements API has not changed, so your old C# Unity code should still work.

To update an existing Unity asset package integration:

  1. Remove all Unity Ads assets from your project
  2. Import the Unity Ads 2.x Asset Package
  3. Test your project

Step 1: Remove all components of the previously imported Unity Ads Package

  • Automatically remove the plugin using the Package Uninstaller,
  • or manually remove the following assets from your project:
    • /Assets/Plugins/Android/unityads/*
    • /Assets/Plugins/iOS/UnityAds.framework
    • /Assets/Plugins/iOS/UnityAds.bundle
    • /Assets/Plugins/iOS/UnityAdsUnityWrapper.h
    • /Assets/Plugins/iOS/UnityAdsUnityWrapper.mm
    • /Assets/Standard Assets/Editor/UnityAds/*
    • /Assets/Standard Assets/UnityAds/*

Step 2: Download and import the Unity Ads 2.x Asset Package

Step 3: Build and test your project

The API for showing an ad is the same as in the previous version of the Unity Ads API.

Rewarded Ad Button Example Code

The Unity Ads Scipting API can be found here.

using UnityEngine;
using UnityEngine.Advertisements;

public class UnityAdsButton : MonoBehaviour
{
    //Inititalize on start
    void Start () 
    {
        if (Advertisement.isSupported) {
            Advertisement.Initialize (gameId, true);
        }
    }

    //show an ad with the "rewardedVideo" placement by calling this method
    void ShowAd ()
    {
        if(Advertisement.IsReady("rewardedVideo")) {
            var options = new ShowOptions();
            options.resultCallback = HandleShowResult;
            Advertisement.Show("rewardedVideo", options);
        }else{
            Debug.Log("Rewarded Video not available");
        }
    }

    //HandleShowResult will be called when the ad stops playing, and pass the result enumerator
    void HandleShowResult (ShowResult result)
    {
        if(result == ShowResult.Finished) {
            Debug.Log("Video completed - Offer a reward to the player");

        }else if(result == ShowResult.Skipped) {
            Debug.LogWarning("Video was skipped - Do NOT reward the player");

        }else if(result == ShowResult.Failed) {
            Debug.LogError("Video failed to show");
        }
    }
}

Update an XCode Project

Latest release (GitHub) | Integration Guide

NOTE: The native iOS API changed between 1.5 -> 2.0, so it may be necessary to update your code.

  1. Remove Unity Ads from your XCode project (Delete UnityAds.Framework & UnityAds.bundle)
  2. Download the latest UnityAds.Framework, and import into your project
  3. Follow our XCode integration guide for native iOS

Update an Android Studio Project

Latest release (GitHub) | Integration Guide

NOTE: The native Android API changed between 1.5 -> 2.0, so it's necessary to update your code.

  1. Remove the 1.5 Unity Ads .JAR or .AAR binary from your Android Studio project.
  2. Download the latest UnityAds binary, and import into your Android Studio project
  3. Follow our Android Studio integration guide to integrate Unity Ads

For Additional questions, please contact us at unityads-support@unity3d.com

Still need help? Get in touch!
Last updated on 20th Aug 2017