2.2.1 游戏广告示例代码如下:
MiracleGames.Advertising.AdvertisingManager.ShowGoogleAd(GoogleAD,Width, Height); MiracleGames.Advertising.AdvertisingManager.ShowGoogleAd("https://googleads.g.doubleclick.net/pagead/ads?ad_type=video_text_image&client=ca-games-pub-6355274975778270&description_url=http%3A%2F%2Flostheart.xxxxxx.com&channel=9404810019&hl=en&max_ad_duration=30000",0, 0);
参数名 |
参数描述 |
GoogleAD | 谷歌广告参数,此参数由MiracleGames申请并提供给开发者 |
Width | 广告的宽 |
Height | 广告的高 |
注意:广告的宽高如需设置建议尺寸不要低于750*610,否则会影响广告展示;如无特殊要求可以设置为全屏(width=0,height=0).
2.2.2 内容广告(728*90,300x300,300x600)示例代码如下:
我方会先用google adsense账号生成自适应广告单元的代码,例如: <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- 开发者-Test --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-9710324349418771" data-ad-slot="1861844728" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> 然后我方会提供data-ad-client,data-ad-slot两个参数,Cp方可以在c#代码中接入如下: AdvertisingManager.GoogleAdClient = "ca-pub-9710324349418771";//google adsense 广告生成的代码中的data-ad-client参数,对应google账号。 AdvertisingManager.GoogleAdSenseURI = "http://www.xxxxxx.com";//之前游戏广告设置的google广告域名url string data_ad_slot="1861844728"; //google adsense 广告生成的代码中的data-ad-slot参数对应的广告单元 GoodAdUI goodAdUI=AdvertisingManager.ShowGoogleAdBanner(null, data_ad_slot); //728x90,横幅,第一个参数是一个父容器。null则代表以页面根元素做为父容器。返回值是一个代表该google广告的ui元素。 AdvertisingManager.ShowGoogleAdTable(null, data_ad_slot);//300x300,插屏 AdvertisingManager.ShowGoogleAdCoupletLeft(null, data_ad_slot);//300x600,对联左 AdvertisingManager.ShowGoogleAdCoupletRight(null, data_ad_slot);//300x600,对联右
如果广告关闭,则会发送该事件。示例代码如下:
MiracleGames.Advertising.AdvertisingManager.GoogleADClosd += GoogleADClosd; void GoogleADClosed(object sender,string e){}
如果google广告未填充,则会发送该事件。示例代码如下:
MiracleGames.Advertising.AdvertisingManager.GoogleADNotFilled += GoogleADNotFilled; void GoogleADNotFilled (object sender,string e){}