LevelPlay component API reference
Use the public methods and events of the LevelPlay components to control ads from your scripts.
Read time 8 minutesLast updated 2 days ago
This page documents the public methods, properties, and events of the four LevelPlay component classes:
- LevelPlay SDK component class
- Banner Ad (LevelPlay) component class
- Interstitial Ad (LevelPlay) component class
- Rewarded Ad (LevelPlay) component class
For the Inspector window properties of each component, refer to LevelPlay component reference.
LevelPlay SDK component class
The class initializes the LevelPlay SDK. Add it once, in the first scene your game loads.
LevelPlaySdkBehaviourRelated API:
LevelPlay.InitMethods
Method | Description |
|---|---|
| Initializes the SDK with the app key for the current platform and the configured user ID. If no app key is set, it logs a warning and does nothing. |
| Same as |
Events
Event | Description | Parameters |
|---|---|---|
| On Init Success | Invoked when the SDK initializes successfully. Invoked on the Unity main thread. | |
| On Init Failed | Invoked when the SDK fails to initialize. Invoked on the Unity main thread. | |
Banner Ad (LevelPlay) component class
The class loads and displays a banner ad at a fixed position on the screen.
LevelPlayBannerAdBehaviourRelated API:
LevelPlayBannerAdMethods and properties
Member | Description |
|---|---|
| Creates the banner from the Inspector settings on the first call, and loads it. |
| Shows the banner. Does nothing before the banner is created. |
| Hides the banner without destroying it. |
| Destroys the banner. The next |
| Pauses or resumes the banner's auto-refresh. |
| Returns the banner's current values. |
| The underlying |
Events
Event | Description | Parameters |
|---|---|---|
| On Ad Loaded | Invoked when the banner loads. | |
| On Ad Load Failed | Invoked when the banner fails to load. | |
| On Ad Displayed | Invoked when the banner becomes visible. | |
| On Ad Display Failed | Invoked when the banner fails to display. | |
| On Ad Clicked | Invoked when the player clicks the banner. | |
| On Ad Expanded | Invoked when the banner expands to cover the screen. | |
| On Ad Collapsed | Invoked when the banner returns from its expanded state. | |
| On Ad Left Application | Invoked when the app goes to the background after the player clicks the banner. | |
| On Ad Impression Data Ready | Invoked when impression-level revenue data is available for this banner. Invoked on the Unity main thread. | |
Interstitial Ad (LevelPlay) component class
The class loads and shows a full-screen interstitial ad, for example between levels. It exposes its settings as public properties, such as , , and , and its events as public properties.
LevelPlayInterstitialAdBehaviourAndroidAdUnitIdLoadOnStartPlacementNameUnityEventRelated API:
LevelPlayInterstitialAdFor an example that uses this class, refer to Show an interstitial ad from a script.
Methods and properties
Member | Description |
|---|---|
| Creates the ad from the Inspector settings on the first call, and loads it. |
| Shows the ad using Placement Name. If no ad is ready, it logs a warning and does nothing. |
| Shows the ad with a specific placement. |
| Returns |
| Returns |
| Destroys the ad. The next |
| Returns the ID of the current ad, or |
| The underlying |
Events
Event | Description | Parameters |
|---|---|---|
| On Ad Loaded | Invoked when the ad loads and is ready to show. | |
| On Ad Load Failed | Invoked when the ad fails to load. | |
| On Ad Displayed | Invoked when the ad opens. | |
| On Ad Display Failed | Invoked when the ad fails to show. | |
| On Ad Clicked | Invoked when the player clicks the ad. | |
On Ad Closed ( | Invoked when the player closes the ad. Resume your game here. | |
| On Ad Info Changed | Invoked when the ad info of a loaded ad changes. | |
| On Ad Impression Data Ready | Invoked when impression-level revenue data is available. Invoked on the Unity main thread. | |
Rewarded Ad (LevelPlay) component class
The class loads and shows a full-screen rewarded ad that grants the player a reward when they finish watching it.
LevelPlayRewardedAdBehaviourRelated API:
LevelPlayRewardedAdFor an example of a method that you connect to On Ad Rewarded in the Inspector window, refer to Grant a reward with a script.
The class has all the methods, properties, and events of the class, plus the following methods and event.
LevelPlayRewardedAdBehaviourLevelPlayInterstitialAdBehaviourMethods
Method | Description | Parameters | Returns |
|---|---|---|---|
| Gets the reward for Placement Name. Use it for pre-show UI, such as "Watch an ad for 100 coins". | None | The reward set for Placement Name, or the ad unit's default reward when no placement is set. |
| Gets the reward for a specific placement. | | The reward for the placement. |
Events
Event | Description | Parameters |
|---|---|---|
| On Ad Rewarded | Invoked when the player earns the reward. Grant the reward here. Don't grant it in On Ad Closed. | |