Knowledge base

Upgrade Guide for Unity - Ads SDK 2.0

The Unity Ads 2.0 SDK supports the existing Unity Ads 1.x plugin API.

You can continue to use your existing integration code. However, you will need to disable or remove any previous version of Unity Ads before importing the 2.0 plugin.

Follow the steps outlined below to upgrade your existing Unity Ads integration.

Please note: the Unity Ads 2.0 SDK plugin for Unity supports Unity 4.7 and later. If you are using an earlier version of Unity, you will either need to upgrade to a compatible version of Unity to use the Unity Ads 2.0 SDK plugin, or continue using the legacy plugin.

Step 1: Disable the Ads service (or remove previously imported Unity Ads plugin).

  • Disabling the Ads Service in Unity 5.2 or later:

    1. Select Window > Services from the menu to view the Services window.
    2. Select the Ads service to view settings for Unity Ads.
    3. Select the toggle switch to turn the Ads service OFF.
  • Removing a previously imported Unity Ads plugin:

    • 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.0 SDK plugin.

Step 3: If you were previously using the Ads service menu integration, add a script to initialize Unity Ads when your game loads. The initialization API is the same as in the previous version of the Unity Ads API.

  1. Open the scene that loads first in your game.
  2. Create a new GameObject in the scene.
  3. Add the following script to the new GameObject.
  4. Replace the example game IDs with your own.
using UnityEngine;
using UnityEngine.Advertisements;

public class UnityAdsInitializer : MonoBehaviour
{
    [SerializeField]
    private string
        androidGameId = "18658",
        iosGameId = "18660";

    [SerializeField]
    private bool testMode;

    void Start ()
    {
        string gameId = null;

        #if UNITY_ANDROID
        gameId = androidGameId;
        #elif UNITY_IOS
        gameId = iosGameId;
        #endif

        if (Advertisement.isSupported && !Advertisement.isInitialized) {
            Advertisement.Initialize(gameId, testMode);
        }
    }
}

Step 4: Build and run your project. The API for showing an ad is the same as in the previous version of the Unity Ads API.

Still need help? Get in touch!
Last updated on 23rd May 2017