반응형
구글 애드몹 SDK 설치
- 코드 작성
using GoogleMobileAds.Api;
using UnityEngine;
public class AdMobManager : MonoBehaviour
{
private NativeExpressAdView nativeAd;
private void Start()
{
MobileAds.Initialize(initStatus => { });
LoadNativeAd();
}
private void LoadNativeAd()
{
AdSize adSize = new AdSize(300, 150); // Set your desired ad size
nativeAd = new NativeExpressAdView("YOUR_AD_UNIT_ID", adSize, AdPosition.Bottom);
AdRequest request = new AdRequest.Builder().Build();
nativeAd.LoadAd(request);
nativeAd.OnAdLoaded += HandleAdLoaded;
}
private void HandleAdLoaded(object sender, EventArgs args)
{
// Native ad loaded successfully, you can now display it
nativeAd.Show();
}
}
반응형