Type Function Return value none Revision Release 2024.3703 Keywords ads, advertising, Unity Ads, init See also unityads.show() unityads.*
unityads.init()
initializes the Unity Ads plugin. This call is required and must be executed before making other Unity Ads calls such as unityads.show().
Once initialized, Unity Ads will automatically start loading ads for the placement IDs you've configured in the Unity Ads dashboard.
unityads.init( listener, params )
Listener. Listener function that will receive adsRequest events.
Table. Table containing Unity Ads initialization values — see the next section for details.
The params
table includes parameters for Unity Ads initialization.
Boolean. Set this value to true
to enable test ads. Default is false
.
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" } )