unityads.show()

Type Function
Return value none
Revision 2018.3321
Keywords ads, advertising, Unity Ads, show
See also unityads.isLoaded()
unityads.*

Overview

Shows a Unity Ads video interstitial or rewarded video ad.

Note

Once you initialize the plugin with unityads.init(), Unity Ads will automatically start loading ads for the placement IDs you've configured in the Unity Ads dashboard.

Syntax

unityads.show( placementId )
placementId (required)

String. One of the placement IDs you've configured in the Unity Ads dashboard.

Example

local unityads = require( "plugin.unityads" )

-- Unity Ads listener function
local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        print( event.provider )
    end
end

-- Initialize the Unity Ads plugin
unityads.init( adListener, { gameId="YOUR_UNITYADS_GAME_ID" } )

-- Sometime later, show an ad
if ( unityads.isLoaded( "YOUR_UNITYADS_PLACEMENT_ID" ) ) then
    unityads.show( "YOUR_UNITYADS_PLACEMENT_ID" )
end