SDK说明


插屏广告

<h1>插屏广告集成相关<a href="https://doc.sigmob.com/ToBid%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/SDK%E9%9B%86%E6%88%90%E8%AF%B4%E6%98%8E/Unity/%E5%B9%BF%E5%91%8A%E7%B1%BB%E5%9E%8B/%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A/#%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A%E9%9B%86%E6%88%90%E7%9B%B8%E5%85%B3">​</a></h1> <h2>1. 接口API说明<a href="https://doc.sigmob.com/ToBid%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/SDK%E9%9B%86%E6%88%90%E8%AF%B4%E6%98%8E/Unity/%E5%B9%BF%E5%91%8A%E7%B1%BB%E5%9E%8B/%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A/#_1-%E6%8E%A5%E5%8F%A3api%E8%AF%B4%E6%98%8E">​</a></h2> <h3>1.1 插屏广告请求类<a href="https://doc.sigmob.com/ToBid%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/SDK%E9%9B%86%E6%88%90%E8%AF%B4%E6%98%8E/Unity/%E5%B9%BF%E5%91%8A%E7%B1%BB%E5%9E%8B/%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A/#_1-1-%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A%E8%AF%B7%E6%B1%82%E7%B1%BB">​</a></h3> <p><strong>Request</strong></p> <table> <thead> <tr> <th>属性成员</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>PlacementId</td> <td>广告位</td> </tr> <tr> <td>UserId</td> <td>媒体用户体系ID ,可选 ,默认null</td> </tr> <tr> <td>options</td> <td>扩展参数,默认null</td> </tr> </tbody> </table> <h3>1.2 插屏视频对象类<a href="https://doc.sigmob.com/ToBid%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/SDK%E9%9B%86%E6%88%90%E8%AF%B4%E6%98%8E/Unity/%E5%B9%BF%E5%91%8A%E7%B1%BB%E5%9E%8B/%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A/#_1-2-%E6%8F%92%E5%B1%8F%E8%A7%86%E9%A2%91%E5%AF%B9%E8%B1%A1%E7%B1%BB">​</a></h3> <p><strong>IntersititialAd</strong></p> <table> <thead> <tr> <th>方法</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>IntersititialAd(Request request)</td> <td>初始化插屏广告对象,request 为广告请求对象,必传</td> </tr> <tr> <td>SetIntersititialAdListener(IIntersititialAdListener listener)</td> <td>设置插屏视频接口回调</td> </tr> <tr> <td>LoadAd()</td> <td>发起广告加载</td> </tr> <tr> <td>Ready()</td> <td>判断当前广告是否存在可展示的广告</td> </tr> <tr> <td>ShowAd()</td> <td>展示广告</td> </tr> <tr> <td>Dispose()</td> <td>销毁广告</td> </tr> <tr> <td>String Placement</td> <td>广告对象使用的广告位</td> </tr> <tr> <td>AdInfo GetAdInfo()</td> <td>获取广告信息AdInfo对象,成功播放回调后获取有效</td> </tr> <tr> <td>List&lt;AdInfo&gt; GetCacheAdInfoList()</td> <td>查询当前广告位的所有缓存信息的AdInfo对象、在广告加载成功后调用。</td> </tr> </tbody> </table> <h3>1.3 插屏广告回调说明<a href="https://doc.sigmob.com/ToBid%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/SDK%E9%9B%86%E6%88%90%E8%AF%B4%E6%98%8E/Unity/%E5%B9%BF%E5%91%8A%E7%B1%BB%E5%9E%8B/%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A/#_1-3-%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A%E5%9B%9E%E8%B0%83%E8%AF%B4%E6%98%8E">​</a></h3> <p><strong>IIntersititialAdListener</strong> 插屏广告回调说明</p> <table> <thead> <tr> <th>回调方法</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>OnAdError (IntersititialAd ad, Error error)</td> <td>广告加载失败</td> </tr> <tr> <td>OnAdLoad (IntersititialAd ad)</td> <td>广告加载成功</td> </tr> <tr> <td>OnAdShow (IntersititialAd ad)</td> <td>广告开始展示</td> </tr> <tr> <td>OnAdClick (IntersititialAd ad)</td> <td>广告被用户点击</td> </tr> <tr> <td>OnSkippedVideo (IntersititialAd ad)</td> <td>用户跳过广告视频播放</td> </tr> <tr> <td>OnVideoEnd (IntersititialAd ad)</td> <td>广告视频播放结束</td> </tr> <tr> <td>OnVideoError (IntersititialAd ad)</td> <td>广告展示失败</td> </tr> <tr> <td>OnAdClose (IntersititialAd ad)</td> <td>广告展示关闭</td> </tr> </tbody> </table> <h2>2. 示例代码<a href="https://doc.sigmob.com/ToBid%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/SDK%E9%9B%86%E6%88%90%E8%AF%B4%E6%98%8E/Unity/%E5%B9%BF%E5%91%8A%E7%B1%BB%E5%9E%8B/%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A/#_2-%E7%A4%BA%E4%BE%8B%E4%BB%A3%E7%A0%81">​</a></h2> <h3>2.1 创建插屏广告广告对象<a href="https://doc.sigmob.com/ToBid%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/SDK%E9%9B%86%E6%88%90%E8%AF%B4%E6%98%8E/Unity/%E5%B9%BF%E5%91%8A%E7%B1%BB%E5%9E%8B/%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A/#_2-1-%E5%88%9B%E5%BB%BA%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A%E5%B9%BF%E5%91%8A%E5%AF%B9%E8%B1%A1">​</a></h3> <pre><code>Request request = new Request(); request.PlacementId = &amp;lt;广告位ID&amp;gt;; request.UserId = &amp;quot;unity_user_1&amp;quot;; IntersititialAd = new IntersititialAd(request);</code></pre> <h3>2.1 设置监听回调<a href="https://doc.sigmob.com/ToBid%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/SDK%E9%9B%86%E6%88%90%E8%AF%B4%E6%98%8E/Unity/%E5%B9%BF%E5%91%8A%E7%B1%BB%E5%9E%8B/%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A/#_2-1-%E8%AE%BE%E7%BD%AE%E7%9B%91%E5%90%AC%E5%9B%9E%E8%B0%83">​</a></h3> <pre><code> private sealed class IntersititialAdListener : IIntersititialAdListener { public void OnAdClick(IntersititialAd ad) { Debug.Log(&amp;quot;SigmobUnityPlugin -- OnAdClick ---- &amp;quot; + ad.PlacementId); } public void OnAdClose(IntersititialAd ad) { Debug.Log(&amp;quot;SigmobUnityPlugin -- OnAdClose ---- &amp;quot; + ad.PlacementId); } public void OnAdShow(IntersititialAd ad) { Debug.Log(&amp;quot;SigmobUnityPlugin -- OnAdShow ---- &amp;quot; + ad.PlacementId); Debug.Log(&amp;quot;SigmobUnityPlugin -- getAdInfo ---- &amp;quot; + ad.GetAdInfo().ToString()); } public void OnAdError(IntersititialAd ad, Error error) { Debug.Log(&amp;quot;SigmobUnityPlugin -- OnAdError ---- &amp;quot; + ad.PlacementId + &amp;quot;, error -- &amp;quot; + error.ToString()); } public void OnAdLoad(IntersititialAd ad) { Debug.Log(&amp;quot;SigmobUnityPlugin -- OnAdLoad ---- &amp;quot; + ad.PlacementId); } public void OnSkippedVideo(IntersititialAd ad) { Debug.Log(&amp;quot;SigmobUnityPlugin -- OnSkippedVideo ---- &amp;quot; + ad.PlacementId); } public void OnVideoEnd(IntersititialAd ad) { Debug.Log(&amp;quot;SigmobUnityPlugin -- OnVideoEnd ---- &amp;quot; + ad.PlacementId); } public void OnVideoError(IntersititialAd ad, Error error) { Debug.Log(&amp;quot;SigmobUnityPlugin -- OnVideoError ---- &amp;quot; + ad.PlacementId + &amp;quot;, error -- &amp;quot; + error.ToString()); } } intersititialAd.SetIntersititialAdListener(new IntersititialAdListener());</code></pre> <h3>2.2 插屏视频广告加载<a href="https://doc.sigmob.com/ToBid%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/SDK%E9%9B%86%E6%88%90%E8%AF%B4%E6%98%8E/Unity/%E5%B9%BF%E5%91%8A%E7%B1%BB%E5%9E%8B/%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A/#_2-2-%E6%8F%92%E5%B1%8F%E8%A7%86%E9%A2%91%E5%B9%BF%E5%91%8A%E5%8A%A0%E8%BD%BD">​</a></h3> <pre><code>intersititialAd.LoadAd();</code></pre> <h3>2.3 插屏广告广告播放<a href="https://doc.sigmob.com/ToBid%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/SDK%E9%9B%86%E6%88%90%E8%AF%B4%E6%98%8E/Unity/%E5%B9%BF%E5%91%8A%E7%B1%BB%E5%9E%8B/%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A/#_2-3-%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A%E5%B9%BF%E5%91%8A%E6%92%AD%E6%94%BE">​</a></h3> <pre><code>if(intersititialAd.Ready()){ intersititialAd.ShowAd(); }</code></pre> <h3>2.4 插屏广告预加载注意事项<a href="https://doc.sigmob.com/ToBid%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/SDK%E9%9B%86%E6%88%90%E8%AF%B4%E6%98%8E/Unity/%E5%B9%BF%E5%91%8A%E7%B1%BB%E5%9E%8B/%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A/#_2-4-%E6%8F%92%E5%B1%8F%E5%B9%BF%E5%91%8A%E9%A2%84%E5%8A%A0%E8%BD%BD%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9">​</a></h3> <ul> <li> <p>需要在平台开启预加载功能。</p> </li> <li> <p>开启预加载功能后,sdk内部会在广告播放中再次去请求广告,成功后会再次回调OnAdLoad。(<strong>相当于load一次广告会有两次onAdLoad</strong>)</p> </li> <li> <p>开启预加载功能后,要注意全局使用同一个IntersititialAd对象。(<strong>new注意判null</strong>)</p> </li> <li> <p>广告播放时可先判断isReady(),如果ready直接播放,否则可再次调用loadAd()。</p> <p>private static IntersititialAd intersititialAd;//全局对象 /**</p> <ul> <li> <p>加载广告 */ void loadAd() {</p> <p>if (intersititialAd == null) { Request request = new Request(); request.PlacementId = &lt;广告位ID&gt;; request.UserId = &quot;unity_user_1&quot;; intersititialAd = new IntersititialAd(request); intersititialAd.SetIntersititialAdListener(new IntersititialAdListener());</p> <p>} </p> <p>intersititialAd.loadAd(); }</p> </li> </ul> </li> </ul>

页面列表

ITEM_HTML