기술 자료

지원

Unity Package integration

Download and integrate the LevelPlay Unity Plugin into your project to enable ad mediation and monetization features.
읽는 시간 4분최근 업데이트: 하루 전

Step 1. Add LevelPlay to your Unity project

You can install the LevelPlay package using two main methods:
  • [Recommended] Add the Ads Mediation package to your project by navigating to Window → Package Manager in Unity. Look for “Ads Mediation” and click the install button. You can also add the package by its name:
    com.unity.services.levelplay
  • Or, Download Unity Plugin Version 9.2.0 (.unitypackage) and import it into your Unity project.
Once installed, the built-in sample allows you to explore & experiment with a working integration of LevelPlay. In the Package Manager's package details view go to Samples, import the LevelPlay Sample and start digging!

Step 2. Initialize the SDK

If you haven't done so already, go to the LevelPlay Platform and create a new app. Once done, use your App Key to initialize the SDK:
  1. Import the namespace: At the top of your C# script, include the namespace:
    using Unity.Services.LevelPlay;
  2. Initialize the SDK: Inside your Start() method, register event listeners and initialize the SDK:
public void Start() { // Register OnInitFailed and OnInitSuccess listeners LevelPlay.OnInitSuccess += SdkInitializationCompletedEvent; LevelPlay.OnInitFailed += SdkInitializationFailedEvent; // SDK init LevelPlay.Init("ThisIsYourAppKey");}
It is important to register OnInitFailed and OnInitSuccess before initializing LevelPlay as they provide you with important insight: OnInitSuccess – triggered when LevelPlay initialized successfully. After you receive this callback, you can start showing ads in your app. OnInitFailed – triggered when LevelPlay failed to initialize and therefore ads will not show. We recommend trying to initialize LevelPlay later (when internet connection is available, or when the failure reason is resolved).

Set UserID

You can pass in a User ID when initializing LevelPlay. This is useful if you're trying to use Ad Quality's User Journey, or if you're using server-to-server callbacks to reward your users.
LevelPlay.Init("ThisIsYourAppKey", "UserId");

Step 3. LevelPlay Network Manager

The LevelPlay Network Manager window is a one stop shop for all things LevelPlay. You can find it in Unity’s top navigation bar, under Ads Mediation. From here, you can:
  • Update your LevelPlay SDK.
  • Install & update your preferred Ad Networks. Once installed, you’ll need to configure each ad network separately. Learn more.
  • Get your app’s Info.plist automatically updated with SKAdNetwork IDs according to the ad networks you have installed.
Starting from LevelPlay Unity package 8.8.1, the Unity Ads adapter will be installed by default, in addition to ironSource Ads. For more information about setting up your Unity Ads account, see Unity Ads Integration Guide.

Android

To apply your changes and download the relevant ad network artifacts, you'll need to use a resolver. Go to: Assets > Mobile Dependency Manager > Android Resolver > Resolve You should do this after each change in the LevelPlay Network Manager. If you're using Gradle, you can avoid downloading the network artifacts into your project. Instead, the artifacts will be added to your Gradle file during the compilation. To enable this process, follow these steps:
  1. Go to: Edit > Project Settings > Player > Android > Publishing Settings
  2. Enable Custom Main Gradle Template
  3. Go to: Assets > Mobile Dependency Manager > Android Resolver > Settings
  4. Select “Patch mainTemplate.gradle”
  5. Save your changes, by pressing “OK”

Step 4. Additional setup

iOS

SKAdNetwork support

If you have SKAdNetwork ID automation disabled, you must manually include the SKAdNetwork ID for each of your installed networks in your app property list file (Info.plist) to enable the display of ads while using SDK 7+:
<key>SKAdNetworkItems</key><array> <dict> <key>SKAdNetworkIdentifier</key> <string>su67r6k2v3.skadnetwork</string> </dict></array>

App transport security settings

  • Add in a dictionary called 'NSAppTransportSecurity'. Make sure you add this dictionary on the 'Top Level Key'.
  • Inside this dictionary, add a Boolean called 'NSAllowsArbitraryLoads' and set it to YES.
  • Make sure that your info.plist does not contain any other exceptions besides 'NSAllowsArbitraryLoads', as this might create a conflict.
  • Find more information on ATS here.

Android

Apps using Android 13+ (API level 33+) will need to declare a Google Play services normal permission in the manifest file as follows:
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
Read more about Google Advertising ID changes here.

Step 5. Verify your integration

The LevelPlay package provides an easy way to verify that your integration was completed successfully with its integration test suite. Test your app’s integration, verify platform setup, and review ads related to your configured networks. To enable the test suite in your app, call the following before initializing the SDK:
LevelPlay.SetMetaData("is_test_suite", "enable");
After successfully initializing LevelPlay, launch the test suite by calling:
LevelPlay.LaunchTestSuite();
For more details and an implementation example of the LevelPlay integration test suite navigate to this article.

Next steps

LevelPlay is now fully configured and ready to go. Follow our integration guides to implement ad formats: