Type Function Return value none Revision Release 2026.3728 Keywords ads, advertising, Unity Ads, load See also unityads.show() unityads.*
Loads a LevelPlay interstitial or rewarded video ad for the given ad unit ID. You must call this before unityads.show() and wait for the "loaded" event.phase before showing.
unityads.load( adUnitId [, adType] )
String. The ad unit ID configured in the LevelPlay dashboard.
String. The type of ad to load. Supported values are "interstitial" (default) and "rewarded".
local unityads = require( "plugin.unityads.v4" )
local interstitialAdUnitId = "YOUR_INTERSTITIAL_AD_UNIT_ID"
local rewardedAdUnitId = "YOUR_REWARDED_AD_UNIT_ID"
-- Unity Ads listener function
local function adListener( event )
if ( event.phase == "init" ) then -- Successful initialization
-- Load ads after init
unityads.load( interstitialAdUnitId )
unityads.load( rewardedAdUnitId, "rewarded" )
elseif ( event.phase == "loaded" ) then
print( "Ad loaded: " .. tostring(event.data) )
end
end
-- Initialize the plugin
unityads.init( adListener, { gameId="YOUR_LEVELPLAY_APP_KEY" } )
-- Sometime later, show an interstitial
if ( unityads.isLoaded( interstitialAdUnitId ) ) then
unityads.show( interstitialAdUnitId )
end