Install and configure the Unity Mediation package
You can install the Unity Mediation package from the Unity Editor Package Manager or add it manually in your project's manifest file.
In a supported Unity Editor version, install the Unity Mediation SDK:
Open your project in the Unity Editor and go to Window > Package Manager.
In the Package Manager window:
- Select Packages > Unity Registry.
- Select Unity Advertisement with Mediation from the list of packages, and then select the most recent verified version.
- Select Install.
You can also add the package manually in your project’s manifest.json file (located at Packages/manifest.json) by adding this line to dependencies section:
When Unity Advertisement with Mediation is successfully installed, it displays in the list of downloaded packages when you select Packages > In Project in the Editor Package Manager.
Import ad network adapters
Open your project in the Unity Editor and select Edit > Project Settings > Services > Unity Mediation or Services > Unity Mediation > Configure.
Enable the adapters for each of your respective Ad Sources. For more information, see Configure an Ad Source.
Applying your adapter settings in the Unity Editor creates a file in your project files (Assets/Editor/MediationAdapterDependencies.xml) that contains mediation dependencies based on your selection of network adapters.
Set specific dependency versions by using XML override
When you install your selected ad network adapters from the Mediation Services window in the Unity Editor, the latest, most compatible version of the adapter SDK is automatically installed. However, there might be instances where you need to manually declare third-party adapters and the respective adapter versions that you will use in your project. For example:
- You are forced to use the latest Xcode due to the newest third-party ad network dependencies, but cannot currently upgrade (for example, because of system incompatibilities)
- You want to avoid using a newer version of Android, AndroidX, or Gradle
- There is a dependency patch was release with breaking API changes
- There is a dependency with a valid version that was released with major issues
- A bug in CocoaPods/Gradle means resolvable dependency tree remains unsolvable (this is an unlikely scenario)
In any of these cases, to manually add any third-party ad network SDK version and ensure compatibility in your project, complete the following steps:
- Create a
Dependency Override XMLfile and name it
- Include this file in your project’s Assets/Editor folder.
Use the following format for the
<dependencies> <androidPackages> <androidPackage spec="adapterName:version"/> </androidPackages> <iosPods> <iosPod name="adapterName" version="x.x.x"> </iosPods> </dependencies>
Install the iOS Support package
To facilitate the implementation of iOS 14.5 requirements (for example, showing a permission popup to request that the user be tracked, and the attribution of shown ads by using SKAdNetworkIds), we recommend that you install the iOS Support package. For more information, see Installing the iOS 14 support package.
If the iOS Support package is installed, then by default, Unity Mediation and the iOS Support package will include all SKAdNetworkIds that are required for the Unity Mediation package, and the list of SKAdNetworkIds will be updated at each build with the latest required SKAdNetworkIds (this is because they are included in the Info.plist of the iOS project).
Projects made with Unity require a dependency resolver to resolve platform-specific dependencies. The Mediation package includes the Mobile Dependency Resolver and it is the recommended tool to use. If no Dependency Resolver is found in the project, a prompt will appear and offer to install the Mobile Dependency Resolver. If you already have a Dependency Resolver you can delete it. If the Mediation package detects that resolution is necessary, you will be prompted to resolve dependencies when you attempt to build an unresolved project.
To access the Mobile Dependency Resolver in the Unity Editor, select Assets > Mobile Dependency Resolver, and then select the platform.
For Android, if the Enable Auto-Resolution and Enable Resolution On Build settings are both set to OFF, you need to manually resolve dependencies. If either setting is ON, then dependencies automatically resolve.
For more information, view this video on how to resolve external dependencies in your project within the Unity Editor.