Skip to main content

Import and Initialize Unity Package

Before you start

Meson supports Unity version 2018.4.18f1 and above.

The download and use of the SDK is subject to the Meson SDK Licensing Terms. If you do not agree to these terms, do not download, access, or use the SDK, or the underlying services.

Download the Meson Unity Package#

You can download the Meson Unity Package here.

Import Meson Unity Package to the project#

In Unity, Go to Assets , go to Import Package and select Custom Package . Navigate to the downloaded Meson Unity Package. Select the package. The package contents will show on Unity. Select All and Import.

unity-integration

unity-integration

Managing and Adding 3rd Party Ad Network dependency#

To edit 3rd Party Ad Network support, edit MesonDependencies.xml

To access MesonDependencies.xml, Go to Assets > Meson > Scripts > Editor > MesonDependencies.xml

<dependencies>
//Mandatory Dependencies
<androidPackages>
<androidPackage spec="ai.meson.sdk:meson:1.0.0-beta11"/>
<androidPackage spec="ai.meson.sdk:meson-core:1.0.1-beta8"/>
<androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10"/>
<androidPackage spec="org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9"/>
<androidPackage spec="org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9"/>
</androidPackages>
//iOS Ad Networks
<iosPods>
<iosPod name="InMobiSDK" version="10.0.1"/>
<iosPod name="MesonInMobiAdapter" version="10.0.1.0-beta5"/>
<iosPod name="Google-Mobile-Ads-SDK" version="8.12.0"/>
<iosPod name="MesonGAMAdapter" version="8.12.0.0-beta5"/>
<iosPod name="MesonAdmobAdapter" version="8.12.0.1-beta5"/>
<iosPod name="MesonSDK" version="1.0.0-beta5"/>
<iosPod name="IronSourceSDK" version="7.1.11.0"/>
<iosPod name="MesonIronSourceAdapter" version="7.1.11.0-beta5"/>
<iosPod name="AppLovinSDK" version="10.3.6"/>
<iosPod name="MesonApplovinAdapter" version="10.3.6.1-beta5"/>
<iosPod name="UnityAds" version="3.7.5"/>
<iosPod name="MesonUnityAdapter" version="3.7.5.0-beta5"/>
<iosPod name="MintegralAdSDK" version="7.0.3"/>
<iosPod name="MesonMintegralAdapter" version="7.0.3.0-beta5"/>
<iosPod name="VungleSDK-iOS" version="6.10.3"/>
<iosPod name="MesonVungleAdapter" version="6.10.3.0-beta5"/>
<iosPod name="FBAudienceNetwork" version="6.9.0"/>
<iosPod name="MesonFANAdapter" version="6.9.0.0-beta5"/>
</iosPods>
// Android Ad Networks
<!-- InMobi -->
<androidPackage spec="com.inmobi.monetization:inmobi-ads:10.0.1"/>
<androidPackage spec="ai.meson.sdk.mediation:inmobi:10.0.1.0-beta4"/>
<!-- Google AdMob -->
<androidPackage spec="com.google.android.gms:play-services-ads:20.4.0"/>
<androidPackage spec="ai.meson.sdk.mediation:admob:20.4.0.0-beta4"/>
<!-- Google Ad Manager -->
<androidPackage spec="com.google.android.gms:play-services-ads:20.4.0"/>
<androidPackage spec="ai.meson.sdk.mediation:gam:20.4.0.0-beta4"/>
<!-- Facebook Audience Network -->
<androidPackage spec="com.facebook.android:audience-network-sdk:6.7.0"/>
<androidPackage spec="ai.meson.sdk.mediation:facebook:6.7.0.0-beta3"/>
<!-- Vungle -->
<androidPackage spec="com.vungle:publisher-sdk-android:6.10.2"/>
<androidPackage spec="ai.meson.sdk.mediation:vungle:6.10.2.0-beta3"/>
<!-- Mintegral -->
<androidPackage spec="com.mbridge.msdk.oversea:mbbid:15.7.41"/>
<androidPackage spec="ai.meson.sdk.mediation:mintegral:15.7.41.0-beta4"/>
<androidPackage spec="com.mbridge.msdk.oversea:reward:15.7.41"/>
<androidPackage spec="com.mbridge.msdk.oversea:interstitialvideo:15.7.41"/>
<androidPackage spec="com.mbridge.msdk.oversea:mbbanner:15.7.41"/>
<androidPackage spec="com.mbridge.msdk.oversea:interstitial:15.7.41"/>
<!-- Unity -->
<androidPackage spec="com.unity3d.ads:unity-ads:3.7.5"/>
<androidPackage spec="ai.meson.sdk.mediation:unity:3.7.5.0-beta4"/>
<!-- App Lovin -->
<androidPackage spec="com.applovin:applovin-sdk:10.3.1"/>
<androidPackage spec="ai.meson.sdk.mediation:applovin:10.3.1.0-beta3"/>
</dependencies>

Initialise the Unity plugin using Meson Manager (Recommended)#

  1. Drag and drop the MesonManager prefab from Assets/Meson/Prefabs onto your scene.

unity-integration

  1. Enter the required settings as per your need.
OptionDescription
Auto Initialise on StartCheck this option to automatically initialise the Meson SDK in Start (). The SDK must be initialised before you can request ads. Leaving it unchecked means you must manually initialise the SDK.
iOS App IDUnique Identifier for a iOS app generated on Meson UI while creating a new app
Android App IDUnique Identifier for a Android app generated on Meson UI while creating a new app
Log levelSpecify log verbosity (‘none’, ‘error’ or ‘debug’) for the Meson SDK.
GDPR ConsentGDPR consent can be passed either as a IAB v1 or v2 string, boolean value.
CallbackSubscribe to initialisation callback to listen to for initialisation event completion lifecycle.
  1. iOS and Android App ID must be set for successful integration.

Initialise the plugin manually#

  1. In the app Start() method, instantiate a Meson.SdkConfiguration object with i. iOS App ID - Unique Identifier for a iOS app generated on Meson UI while creating a new app ii. Android App ID - Unique Identifier for a Android app generated on Meson UI while creating a new app iii. Log level - Specify log verbosity (‘none’, ‘error’ or ‘debug’) for the Meson SDK. iv. Consent (optional) - GDPR consent can be passed either as a IAB v1 or v2 string, boolean value.
  2. Call Meson.InitializeSDK() and pass the Meson.SdkConfiguration Object
Dictionary<string, string> consentDictionary = new Dictionary<string, string>();
consentDictionary.Add(Meson.MESON_GDPR_CONSENT_AVAILABLE, "true");
consentDictionary.Add(Meson.MESON_GDPR_CONSENT_GDPR_APPLIES, "0");
consentDictionary.Add(Meson.MESON_GDPR_CONSENT_IAB, "IAB String v1 or v2");
Meson.InitializeSdk(new Meson.SdkConfiguration
{
AndroidAppId = "12345",
IOSAppId = "1234",
LogLevel = Meson.LogLevel.Debug,
ConsentDict = consentDictionary
});
  1. Register for onSDKInitializedEvent callback event.
// register for initialized callback event in the app
MesonManager.SdkInitializedEvent += OnSdkInitializedEvent;
// create your handler
private void OnSdkInitializedEvent(string adUnitId)
{
// The SDK is initialized here. Ready to make ad requests.
}

Add User Data#

Note
  • To use cohorts in Meson UI, this is where you will need to set PPID unique to a user
  • To use segments or experiments in Meson UI, this is where you will need to send the segments or experiments.

This is optional. In case you want to send us any information about the user, please do as follows:

Dictionary<string, dynamic> extrasDictionary = new Dictionary<string, dynamic>();
extrasDictionary.Add("gender", 1);
extrasDictionary.Add("age", 18);
string[] segments = { "s1", "s2", "s3" };
extrasDictionary.Add("segments", segments);
Meson.SetExtras(extrasDictionary);