In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the relevant knowledge of what the Admob Unity plug-in access method is, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this Admob Unity plug-in access method. Let's take a look at it.
Introduction to the Admob Unity plug-in
The Admob Unity plug-in provides a way to integrate admob advertising into Unity3D Game and U3D applications. You can use it for Unity iOS and Android App with the same c # or js code.
Is the Admob SDK plug-in for Unity3d, which makes it easier for js and c # developers to add Google ads to Unity3d games, supports iOS and Android, and supports admob plug-in ads and banners
Admob Unity plug-in description
Google Mobile Advertising SDK is the latest generation of Google mobile advertising products, with a complete advertising format and simplified API, access to mobile advertising networks and advertising solutions. This SDK enables Unity mobile application developers to make the most of native mobile applications.
The repository contains the source code for the Google Mobile Ads Unity plug-in. The plug-in makes it easy for Unity developers to place Google mobile ads on Android and iOS applications without writing Java or Objective-C code. The plug-in provides a C # interface for requesting advertisements used by C # scripts in the Unity project.
Unity Admob plug-in function
A platform supported by plug-ins:
Android, through SDK v18.3.0 (part of the Google Play services platform)
IOS, via SDK v7.53
Support for all local events
AdRequest positioning methods, such as child positioning, test mode
There is no need to change the Android package name
Very simple API
Support for non-personalized advertising
Type of advertisement:
Slogans (all slogan types and custom banner sizes)
Insert ads (text, pictures, videos)
Reward video
Advanced native advertising
Download the Admob Unity plug-in and install Admob Unity
Open your project in the Unity editor.
Navigate to Assets- > Import Package- > Custom Package.
Select the admob_unity_plugin.unitypackage file.
Import all files except admobdemo.cs (sample script) by selecting Import. Make sure to check for any conflicts with the file.
You can install and copy the files in the folder plug-in directly into the Unity3d project by downloading the files.
Unity plug-in Wiki and documentation
Explain
API
Literature
Quickly start editing AndroidManifest.xml and configuring Admob APP ID
Admob requires this configuration since version 17. 0, and if it is not configured, APP will crash. Add metadata tags in the application and set the value to admob appid
Sample code
Edit Info.plist, add appid
GADApplicationIdentifier ca-app-pub-xxxxxxxxxxxxxxxxxxxxxx~xxxxxxxxxxxxxx
Configure the exported Xcode project, build Settings-> other linker flags, add flags-ObjC
1.Init Admob Unity plug-in
Create an AC# script, drag and drop the script onto an object in the scene, and add the following code to the script file
Using admob; Admob.Instance () .initSDK (new AdProperties ()); / / admob id configed in meta,not support in code any more
You can set the admob property as follows. You need to set the property to be set.
AdProperties adProperties = new AdProperties (); adProperties.isTesting (true); / / true for test ads adProperties.isAppMuted (true); adProperties.isUnderAgeOfConsent (false); adProperties.appVolume; adProperties.maxAdContentRating (AdProperties.maxAdContentRating_G); string [] keywords = {"key1", "key2", "key3"}; adProperties.keyworks (keywords); 2. Add Admob Banner to Unity App
This is the minimum amount of code required to display the admob banner.
Admob.Instance () .showBannerRelative ("your admob banner unit id", AdSize.BANNER, AdPosition.BOTTOM_CENTER, 0)
Or you can create another banner by setting the banner name
Admob.Instance () .showBannerAbsolute ("ca-app-pub-3940256099942544/6300978111", AdSize.BANNER, 20220, "mybanner")
The AdPosition class specifies where to place the banner. AdSize specifies the witch size banner to display
3. Delete a banner
By default, banners are visible. To hide the banner, call:
Admob.Instance (). RemoveBanner (); 4. How to integrate off-page ads into Unity 3D applications?
This is the minimum code to create insert ads.
Admob.Instance () .loadInterstitial (Your admob interstitial unit id)
Unlike banner ads, insert ads need to be clearly displayed. At the appropriate stop point for the application, check that the plug-in ad is ready before it is displayed:
If (Admob.Instance (). IsInterstitialReady ()) {Admob.Instance () .showInterstitial ();} 5, custom Admob banner ad size
In addition to the constants on AdSize, you can also create custom dimensions:
/ / Create a 250x250 banner. AdSize adSize = new AdSize (250,250); Admob.Instance (). ShowBannerAbsolute ("Your admob banner id", adSize,0,30, "bannerName"); 6. How to integrate Admob reward video into Unity3d applications?
This is the minimum code to create an admob video.
Admob.Instance () .loadRewardedVideo (ca-app-pub-3940256099942544/1712485313)
Videos similar to plug-in videos need to be clearly displayed at the appropriate stop point in your application, please check that the video is ready before displaying the video:
If (Admob.Instance (). IsRewardedVideoReady ()) {Admob.Instance () .showRewardedVideo ();} 7, display Admob native premium ads in iOS and Android App
This is the minimum amount of code required to display the admob banner. This is achieved through Admob Native Advertising Premium (Unified).
Admob.Instance () showNativeBannerRelative ("Your native banner id", new AdSize (360100), AdPosition.BOTTOM_CENTER); 8. Advertising campaign
These two banners and interstitial contain that you can register for the same advertising campaign. Here, we will demonstrate setting ad events on plug-in ads and displaying plug-in ads when loading successfully:
Admob.Instance () .interstitialEventHandler + = onInterstitialEvent; void onInterstitialEvent (string eventName, string msg) {Debug.Log ("handler onAdmobEvent---" + eventName + "" + msg); if (eventName = = AdmobEvent.onAdLoaded) {Admob.Instance () .showInterstitial ();}}
You only need to register the events you care about.
Unity Admob demo usage
Import AdmobUnityPlugin.unitypackage into your Unity project
Copy Admobdemo.cs from AdmobPluginRes to your unified project / asset dic
Attach admobdemo.cs to the main camera
Edit admob ID in admobdemo.cs
Build and run on your device
Add-ObjC flag to xcode other linker flag 7 add meta application key to Xcode Info.plist
GADApplicationIdentifier ca-app-pub-xxxxxxxxxxxxxxxxxx~xxxxxxxxxx
Important hint
If you do not configure AndroidManifest.xml, the application will crash
If you do not add the-ObjC flag, the application will crash
If you do not add GADApplicationIdentifier to Info.plist, the application will crash
Attach admob to objects in the scene and initialize admob before calling admob fun
Screenshot
This is the end of the article on "what is the way to access the Admob Unity plug-in?" Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "what is the method of Admob Unity plug-in access". If you want to learn more knowledge, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.