Skip to main content

Playable API

To ensure your playable is compatible with the supported networks, it is important to implement a handful of global functions so that Luna knows how to appropriately map your game logic to the playable networks' specifications.

Luna makes this simple by providing a single C# API, which is then tailored for the network at time of export with no additional work for you.

Handling screen orientation

We recommend that you build a responsive playable ad, and ensure that the UI and other elements scale or adapt accordingly. In a playable ad context, you will not have access to Unity APIs such as Input.deviceOrientation. Therefore we recommend using Screen.width and Screen.height to handle this.

float screenRatio = (Screen.width/Screen.height);
if (screenRatio >= 1) {
// Landscape Layout
} else if (screenRatio < 1) {
// Portrait Layout
}

App Store Clicks (CTAs)

When you wish to direct a user to the app store in your playable ad i.e. after clicking the in-game CTA button, or end card, then you need to call the following API from your game code:

Luna.Unity.Playable.InstallFullGame();

Pausing and Resuming Gameplay

In order to pause the gameplay when the app is sent to the background or the app store link is clicked, Luna provides lifecycle events to which you can subscribe.

For example, it is recommended to pause the gameplay when the user leaves the app, or you may wish to present the end card after the user has returned.

Please use the Luna.Unity.LifeCycle.OnResume and Luna.Unity.LifeCycle.OnPause events. For example:

Luna.Unity.LifeCycle.OnPause += PauseGameplay;
Luna.Unity.LifeCycle.OnResume += ResumeGameplay;

...
...

private void PauseGameplay() {

// Pause the game
}

private void ResumeGameplay() {

// Resume the game
}

Game Ended lifecycle event

Some networks require that you notify them when the end of the playable ad is reached. This event must be called when the experience is complete, for example, when the end card is presented.

Luna.Unity.LifeCycle.GameEnded();
Warning

The current networks which require this are:

  • Mintegral
  • Vungle

Testing your builds

Every ad network has their own specification and toolset for testing playables. See the following guides for how to test for each ad network.