Unity Engine Integration

What’s new in 5.0

Publishers upgrading to the 5.0 MoPub SDK are required to take additional steps. Reference our guides for SDK Initialization and GDPR for more details on how to stay up-to-date and compliant.

Introduction

Unity developers can easily integrate the MoPub SDK along with our mediation adapters via Unity packages. We support Unity 5.5 and above. Follow these steps:

Getting Started

  1. Download the latest MoPub Unity plugin here.

  2. If you would like to use mediation, download the mediation adapters here.

  3. Import the MoPubUnityPlugin.unitypackage and the adapters via corresponding .unitypackage binaries into your Unity project.

  4. Switch back to Unity. Upon importing MoPubUnity.unitypackage, you will see several modular jars of the new modular Android SDK for all versions 4.9.0 and newer:
    • mopub-sdk-base.jar
    • mopub-sdk-banner.jar
    • mopub-sdk-interstitial.jar
    • mopub-sdk-rewardedvideo.jar
    • android-support-v4-x.y.z.jar
    • mopub-unity-plugins.jar
    • mopub-volley-2.0.0.jar

    All mopub-sdk-* jars are required. Keep all files selected in the Importing Package window and click Import.

    Note: Native ad is currently not supported.

  5. To mediate third-party ad networks, download the certified network SDKs here and place them in your Unity project:

    SDK File Type Path to place the network SDKs Note
    Android (.aar) [UNITY PROJECT ROOT]/Assets/Plugins/Android  
    Android (.jar) [UNITY PROJECT ROOT]/Assets/Plugins/Android/mopub-support/libs  
    iOS (.framework) [UNITY PROJECT ROOT]/Assets/Plugins/iOS Manually add the frameworks to your project after exporting it to Xcode if need be†

    Note: For publishers using MoPub plugin version 5.0+ and Unity version below 2017.1 and building for iOS should do the following: 1) Update to MoPub plugin version 5.0.1 or above. 2) After exporting your project into Xcode, select the project root folder in the left pane, then select the General tab in the center pane. 3) Find the Embedded Binaries section and click the + button. 4) Scroll down the list of frameworks until you see Plugins/iOS/MoPubSDKFramework.framework. Select it and click Add.

    Additionally, check out this page for instructions of importing mediation adapters.

  6. Instantiate the plugin for each ad format. You have to pass in a String array of adunit IDs to the methods as shown in the MoPubDemoGUI.cs file:

     MoPub.LoadBannerPluginsForAdUnits(_bannerAdUnits);
     MoPub.LoadInterstitialPluginsForAdUnits(_interstitialAdUnits);
     MoPub.LoadRewardedVideoPluginsForAdUnits(_rewardedVideoAdUnits);
     MoPub.LoadRewardedVideoPluginsForAdUnits(_rewardedRichMediaAdUnits);
    
  7. Choose the format you’d like to integrate and follow the instructions for each format.

Conversion Tracking

Here’s how to report a conversion/app open event:

MoPub.reportApplicationOpen("iTunesAppID");

Here’s how to enable/disable location passing:

MoPub.enableLocationSupport(true);

MoPub.enableLocationSupport(false);

Known Limitations

  • Plugins for the Unity engine do not mediate native ad formats.
  • Developers should test to verify compatibility with other third party plugins.

Last updated July 10, 2018

TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.

© 2018 MoPub Inc.