且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Unity Admob与Google Play游戏服务集成

更新时间:2023-02-02 19:35:15

您提到的上述资源已经陈旧。鉴于Google现在已在Unity游戏引擎上对AdMob提供官方支持。

The above resources you mentioned are old. Whereas now google has official support for AdMob on Unity game engine.

在此处获取官方插件- https://github.com/googleads/googleads-mobile-plugins/blob/master/README.md

Get the official plugin here -https://github.com/googleads/googleads-mobile-plugins/blob/master/README.md

-导入整个程序包。修改您的androidmanifest.xml以包含许可权和活动名称。

-Import the whole package. Modify your androidmanifest.xml to include the permission and activity name.

-在您的/ extras / google / google_google_play_services / libproject中添加google-play-services_lib文件夹sdk,放到您项目的Plugins / Android文件夹中。

-Add the google-play-services_lib folder, located at /extras/google/google_play_services/libproject in your sdk, into the Plugins/Android folder of your project.


  • 要在C#脚本中包含基本横幅的代码:-


使用GoogleMobileAds.Api;

using GoogleMobileAds.Api;

//创建

BannerView bannerView = new BannerView( YOUR_AD_UNIT_ID,AdSize.Banner,AdPosition.Top);

BannerView bannerView = new BannerView("YOUR_AD_UNIT_ID", AdSize.Banner, AdPosition.Top);

//创建一个空广告请求。

// Create an empty ad request.

AdRequest request = new AdRequest.Builder()。Build();

AdRequest request = new AdRequest.Builder().Build();

//用请求加载横幅。

// Load the banner with the request.

bannerView.LoadAd(request);

bannerView.LoadAd(request);

您将能够在附加了特定脚本的级别的顶部看到广告。

And you would be able to see Ads on the top of your level on which that particular script is attached.