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:

  1. Open your project in the Unity Editor and go to Window > Package Manager.

  2. In the Package Manager window:

    1. Select Packages > Unity Registry.
    2. Select Unity Advertisement with Mediation from the list of packages, and then select the most recent verified version.
    3. Select Install.

Note: If you created your project through the Unity Editor flow, you must also link it to a Unity Dashboard Project ID before it can access Unity Gaming Services. See Configuring projects for Unity Gaming Services.

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:

"": "1.0.4".

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.

Note: The Mediation package includes Unity Ads libraries.

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.

Note: AdMob requires unique identifiers for each platform. You can locate these IDs in the AdMob dashboard. See Retrieve your AdMob credentials.

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:

  1. Create a Dependency Override XML file and name it OverrideDependencies.xml.
  2. Include this file in your project’s Assets/Editor folder.

Use the following format for the OverrideDependencies.xml file:

      <androidPackage spec="adapterName:version"/>  
      <iosPod name="adapterName" version="x.x.x">

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).

Resolve dependencies

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.