https://github.com/unity-package/native-ads-unity
Admob Native Ads for Unity integration
https://github.com/unity-package/native-ads-unity
integrate-native-ads native-ads native-ads-unity unity unity3d
Last synced: 3 days ago
JSON representation
Admob Native Ads for Unity integration
- Host: GitHub
- URL: https://github.com/unity-package/native-ads-unity
- Owner: unity-package
- Created: 2024-11-29T02:53:48.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-11-29T04:12:41.000Z (7 months ago)
- Last Synced: 2025-06-09T00:37:56.906Z (13 days ago)
- Topics: integrate-native-ads, native-ads, native-ads-unity, unity, unity3d
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Native ads for Unity
Tool native ads for Unity## Adding the SDK
### 1. Add the Google Mobile Ads plugin to your project
- [Download](https://github.com/googleads/googleads-mobile-unity/releases) and import Google Mobile Ads plugin
### 2. Add the GoogleMobileAds-native and ToolNativeAd to your project
- [Download](https://github.com/unity-package/native-ads-unity/releases) and import GoogleMobileAds-native and ToolNativeAd sdk### 3. Force resolve dependencies
Force resolve the dependencies from Assets/External Dependency Manager/Android Resolver/Force Resolve if the resolver did not open automatically.## Setup Id
### 1. Add AdMob app ID
- You can open this from Assets/Google Mobile Ads/Settings

- Add the AdMob application IDs here

### 2. Add NativeAd ID
- Via `Tools -> NativeAd Settings` to open NativeAdSettings Window

- Add Native Ads Ids here

- `Use TestMode` equals `true`, you will use the Google Mobile Ads test Id
## Scene setup
### 1. Drag and Drop `NativeAdHolderTemplate` prefab
- Drag and drop any of the Native ad unit prefab from the path `Assets > ToolNativeAd > Prefabs > NativeAdHolderTemplate` into your gameplay scene.


### 2. Edit `NativeAdHolderTemplate`
- Edit the size, layout and image PlaceHolder in NativeAdHolder to suit your needs
(Note: When the ad fails to load, PlaceHolder will display)
## Handle Script
### 1. FetchAd, Adtive and Block
```csharp
public NativeAdHolder nativeAdHolder;///
/// Fetch and show Native Ad
///
public void FetchAd()
{
nativeAdHolder.FetchAd();
}///
/// Hide visual NativeAd and show PlaceHolder
///
public void BlockAd()
{
nativeAdHolder.Block();
}///
/// Show visual NativeAd and hide PlaceHolder
///
public void ActiveAd()
{
nativeAdHolder.Active();
}
```Note: In some cases the click goes through the popup and triggers the NativeAd, call the `Block` method to prevent this. The `Active` method is the opposite of `Block`
### 2. Tracking revenue
```csharp
public NativeAdHolder nativeAdHolder;
private void OnEnable()
{
nativeAdHolder.Event_OnAdPaid += OnAdPaid;
}private void OnDisable()
{
nativeAdHolder.Event_OnAdPaid -= OnAdPaid;
}private void OnAdPaid(AdValue adValue)
{
Debug.Log(adValue.CurrencyCode);
Debug.Log(adValue.Value);
}
```
- Use the `Event OnAdPaid` event to register a callback to perform tracking