unityads.isLoaded()

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

Overview

Returns a boolean indicating whether an ad is loaded and ready for display.

Note

Calling this function will also trigger an adsRequest event with a phase of "placementStatus". For this event, event.data will contain additional information about the status of the placement ID.

Syntax

unityads.isLoaded( 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, { appId="YOUR_UNITYADS_GAME_ID" } )

-- Sometime later, check if an ad (placement ID) is ready for display
print( unityads.isLoaded( "YOUR_UNITYADS_PLACEMENT_ID" ) )