Unity Engine Integration
- What’s new in 5.0
- Integrate the Plugin and Adapters
- Getting Started with Ads
- Conversion Tracking
- Known Limitations
What’s new in 5.0
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:
Integrate the Plugin and Adapters
Download the latest MoPub Unity plugin here.
If you would like to use mediation, download the mediation adapters here.
To import the MoPub Unity plugin, double-click on the
MoPubUnityPlugin.unitypackage, or go to
Assets > Import Package > Custom Package.
MoPubUnity.unitypackage, keep all files selected in the
Importing Packagewindow and click
To import the mediation adapters, double-click on the corresponding network
.unitypackageor go to
Assets > Import Package > Custom Package. Take AdMob for example:
To mediate third-party ad networks, download the certified network SDKs from the link in the MoPub Mediation Integration Tool > Your Network Name > Learn More. Please make sure you are using the cerified version.
Note: Some networks might also provide a Unity version of their SDK. For AdColony, you need to use its Unity SDK specifically. For other networks, make sure to always download their native Android and iOS SDKs instead in this integration.
Place the network SDKs in your Unity project according to the file extensions, like so:
SDK File Type Path to place the network SDKs Note Android (.aar)
[UNITY PROJECT ROOT]/Assets/Plugins/Android
If required by networks, add Google Play services aars to this directory. Android (.jar)
[UNITY PROJECT ROOT]/Assets/Plugins/Android/mopub-support/libs
If required by networks, add Google Play services jars to this directory. iOS (.framework)
[UNITY PROJECT ROOT]/Assets/Plugins/iOS
Manually add the frameworks to your project after exporting it to Xcode if need be†
Before you build your app project, for Android, make sure to add required
<Activity>for specific networks if needed (to the
AndroidManifest.xml). Please check out the networks’ Android integration guide for details.
Build and run your Unity project. For iOS, after exporting your project into Xcode, ensure
MoPubSDKFramework.frameworkis in the
Embedded Binarieslist. Otherwise click the
+button to add it.
MoPubSDKFramework.frameworkand other network frameworks are in the
Linked Frameworks and Librarieslist. Otherwise, click the
+button to add them.
† Note: For publishers using MoPub plugin version 5.0+ and Unity version below 2017.1 on iOS, make sure to update to MoPub plugin version 5.0.1 or higher, and review the above steps.
Getting Started with Ads
Follow this instruction to initialize the SDK.
Instantiate the plugin for each ad format. You have to pass in a
Stringarray of adunit IDs to the methods as shown in below:
MoPub.LoadBannerPluginsForAdUnits(_bannerAdUnits); MoPub.LoadInterstitialPluginsForAdUnits(_interstitialAdUnits); MoPub.LoadRewardedVideoPluginsForAdUnits(_rewardedVideoAdUnits); MoPub.LoadRewardedVideoPluginsForAdUnits(_rewardedRichMediaAdUnits);
Choose the format you’d like to integrate and follow the instructions for each format:
Additionally, check out this page for other instructions of mediation integration.
Here’s how to report a conversion/app open event:
Here’s how to enable/disable location passing:
- Plugins for the Unity engine do not mediate native ad formats.
- Developers should test to verify compatibility with other third party plugins.
Last updated September 07, 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.