unityads.isLoaded()

Type Function
Return value Boolean
Revision Release 2022.3683
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.

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.v4" )

-- 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" ) )