unityads.load()

类型 函数
返回值
修订 版本 2024.3703
关键词 广告, Unity 广告, 显示
另请参阅 unityads.show()
unityads.*

概述

加载 Unity 广告视频插播广告或激励视频广告。

语法

unityads.load( placementId )
placementId (必填)

字符串. 您在 Unity 广告 控制面板 中配置的其中一个广告位 ID。

示例

local unityads = require( "plugin.unityads.v4" )

-- Unity Ads listener function
local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        print( event.provider )
    --Load ad before we show
    unityads.load("YOUR_UNITYADS_PLACEMENT_ID")
    end
end

-- Initialize the Unity Ads plugin
unityads.init( adListener, { gameId="YOUR_UNITYADS_GAME_ID" } )

-- Sometime later, show an ad
if ( unityads.isLoaded( "YOUR_UNITYADS_PLACEMENT_ID" ) ) then
    unityads.show( "YOUR_UNITYADS_PLACEMENT_ID" )
end