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() or unityads.load().
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.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, { gameId="YOUR_UNITYADS_GAME_ID" } )