unityads.v4.*

Type Library
Revision Release 2022.3683
Keywords ads, advertising, Unity Ads
Platforms Android, iOS

Overview

The Unity Ads plugin allows developers to monetize users through Unity Ads video interstitial and rewarded video ads.

Important

This documentation is for the new Unity Ads SDK(v4), click to view the Unity Ads legacy plugin

Notable changes from old plugin include now needing to load placement IDs via unityads.load() and the placementStatus event.phase removal.

On a per-app basis, the first time a Unity ad appears, the user will see a banner with the option to opt-out of behaviorally targeted advertising. Thereafter, the user can click an information button to receive the opt-out again. Although UnityAds will automatically present users with an opportunity to opt-out of targeted advertising, with no implementation needed from the publisher, check out new setHasUserConsent method to enable manual GDPR data collection restrictions.

See more at Unity Ads GDPR Compliance doc page

Registration

Before you can use this plugin, you must register with Unity Ads.

Syntax

local unityads = require( "plugin.unityads.v4" )

Functions

Events

Project Settings

To use this plugin, add an entry into the plugins table of build.settings. When added, the build server will integrate the plugin during the build phase. 

settings =
{
    iphone =
    {
        plist =
        {
            NSUserTrackingUsageDescription = "Your data will be used to provide you a better and personalized ad experience.",
            SKAdNetworkItems = {
                { SKAdNetworkIdentifier = "4dzt52r2t5.skadnetwork" },
                { SKAdNetworkIdentifier = "bvpn9ufa9b.skadnetwork" },
            },
        },
    },
    android =
    {
        minSdkVersion = "19",
    },
    plugins =
    {
        ["plugin.unityads.v4"] =
        {
            publisherId = "com.solar2d"
        },
    },
}
Important

If you are building for Android, you should remove any legacy inclusion of the ["plugin.google.play.services"] plugin from your build.settings.

Note

For Android, the following permissions/features are automatically added when using this plugin:

  • "android.permission.INTERNET"
  • "android.permission.ACCESS_NETWORK_STATE"
  • "com.google.android.gms.permission.AD_ID"

Also, minimum Android API level required is 19

Support