Class Advertisement
The wrapper class used to interact with the Unity Ads SDK.
Namespace: UnityEngine.Advertisements
Syntax
public static class Advertisement
Properties
debugMode
Returns true
if the SDK is is in debug mode, and false
if it isn't. Debug mode controls the level of logging from the SDK.
Declaration
public static bool debugMode { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
isInitialized
Returns true
if the SDK is initialized successfully, and false
if it isn't.
Declaration
public static bool isInitialized { get; }
Property Value
Type | Description |
---|---|
Boolean |
isShowing
Returns true
if an ad is currently showing, and false
if it isn't.
Declaration
public static bool isShowing { get; }
Property Value
Type | Description |
---|---|
Boolean |
isSupported
Returns true
if the SDK is supported on the current platform, and false
if it isn't.
Declaration
public static bool isSupported { get; }
Property Value
Type | Description |
---|---|
Boolean |
version
Returns the current SDK version.
Declaration
public static string version { get; }
Property Value
Type | Description |
---|---|
String |
Methods
AddListener(IUnityAdsListener)
Adds a listener that will recieve Unity Ads callbacks. SDK versions 3.1+ allow you to register multiple listeners. This is especially helpful for mediation customers.
Declaration
public static void AddListener(IUnityAdsListener listener)
Parameters
Type | Name | Description |
---|---|---|
IUnityAdsListener | listener | A listener for Unity Ads callbacks. |
GetPlacementState()
Returns the state of the default Placement.
Declaration
public static PlacementState GetPlacementState()
Returns
Type | Description |
---|---|
PlacementState |
GetPlacementState(String)
Returns the state of a specified Placement.
Declaration
public static PlacementState GetPlacementState(string placementId)
Parameters
Type | Name | Description |
---|---|---|
String | placementId | The unique identifier for a specific Placement, found on the developer dashboard. |
Returns
Type | Description |
---|---|
PlacementState |
Initialize(String)
Initializes the SDK with a specified Game ID.
Declaration
public static void Initialize(string gameId)
Parameters
Type | Name | Description |
---|---|---|
String | gameId | The platform-specific Unity game identifier for your Project, found on the developer dashboard. |
Initialize(String, Boolean)
Initializes the SDK with a specified Game ID and test mode setting.
Declaration
public static void Initialize(string gameId, bool testMode)
Parameters
Type | Name | Description |
---|---|---|
String | gameId | The platform-specific Unity game identifier for your Project, found on the developer dashboard. |
Boolean | testMode | Test mode allows you to test your integration without serving live ads. Use |
Initialize(String, Boolean, Boolean)
Initializes the SDK with a specified Game ID, test mode setting, and Placement load setting.
Declaration
public static void Initialize(string gameId, bool testMode, bool enablePerPlacementLoad)
Parameters
Type | Name | Description |
---|---|---|
String | gameId | The platform-specific Unity game identifier for your Project, found on the developer dashboard. |
Boolean | testMode | Test mode allows you to test your integration without serving live ads. Use |
Boolean | enablePerPlacementLoad | Enable the load API lifecycle. See Load(String) for more information. |
IsReady()
Returns true
if an ad is available to display on the default Placement, and false
if it isn't.
Declaration
public static bool IsReady()
Returns
Type | Description |
---|---|
Boolean |
IsReady(String)
Returns true
if an ad is available to display for a specified Placement, and false
if it isn't.
Declaration
public static bool IsReady(string placementId)
Parameters
Type | Name | Description |
---|---|---|
String | placementId | The unique identifier for a specific Placement, found on the developer dashboard. |
Returns
Type | Description |
---|---|
Boolean |
Load(String)
Loads ad content for a specified Placement. If you initialized the SDK with enablePerPlacementLoad
enabled, you must call Load
before calling Show
. Note that the Load
API is in beta and available upon invite only. If you would like to be considered for the beta, please contact us at unityads-support@unity3d.com.
Declaration
public static void Load(string placementId)
Parameters
Type | Name | Description |
---|---|---|
String | placementId | The unique identifier for a specific Placement, found on the developer dashboard. |
See Also
RemoveListener(IUnityAdsListener)
Allows you to remove an active listener.
Declaration
public static void RemoveListener(IUnityAdsListener listener)
Parameters
Type | Name | Description |
---|---|---|
IUnityAdsListener | listener | A listener for Unity Ads callbacks. |
SetMetaData(MetaData)
Sets various metadata for the SDK.
Declaration
public static void SetMetaData(MetaData metaData)
Parameters
Type | Name | Description |
---|---|---|
MetaData | metaData | A metadata container. |
Show()
Displays an ad in the default Placement if it is ready.
Declaration
public static void Show()
See Also
Show(String)
Displays an ad in a specified Placement if it is ready.
Declaration
public static void Show(string placementId)
Parameters
Type | Name | Description |
---|---|---|
String | placementId | The unique identifier for a specific Placement, found on the developer dashboard. |
See Also
Show(String, ShowOptions)
Displays an ad in a specified Placement if it is ready, and passes a ShowResult
enum to the ShowOptions.resultCallback
callback when the ad finishes.
Declaration
public static void Show(string placementId, ShowOptions showOptions)
Parameters
Type | Name | Description |
---|---|---|
String | placementId | The unique identifier for a specific Placement, found on the developer dashboard. |
ShowOptions | showOptions | A collection of options, including |
Show(ShowOptions)
Displays an ad in the default Placement if it is ready, and passes a ShowResult
enum to the ShowOptions.resultCallback
callback when the ad finishes.
Declaration
public static void Show(ShowOptions showOptions)
Parameters
Type | Name | Description |
---|---|---|
ShowOptions | showOptions | A collection of options, including |