unityads.show()

类型 函数
返回值
修订版 2024.3703 版
关键词 广告、Unity Ads、展示
另请参见 unityads.isLoaded()
unityads.*

概述

展示一个 Unity Ads 视频插页广告或激励视频广告。

注意

与先前的插件不同,你现在需要使用 unityads.load() 加载展示位 ID,并且会收到一个 event.phase 已加载

语法

unityads.show( placementId )
placementId (必需)

字符串. 您在 Unity Ads 仪表盘 中配置的一个展示位 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