https://wmmu.tistory.com/entry/%EC%9C%A0%EB%8B%88%ED%8B%B0-%EC%95%A0%EB%93%9C%EB%AA%B9-2023
유니티 애드몹 2023
https://wmmu.tistory.com/entry/FireBase-%EC%95%A0%EB%93%9C%EB%AA%B9 유니티 애드몹 2021 얘내들은 툭하면 API를 바꾼다. 개빡칠노릇 설명서 developers.google.com/admob/unity/quick-start?hl=ko 해당링크에서 들어가보면 이런걸
wmmu.tistory.com
2023판
21판은 API 30까지만 지원된다
얘내들은 툭하면 API를 바꾼다. 개빡칠노릇
설명서
developers.google.com/admob/unity/quick-start?hl=ko
해당링크에서 들어가보면 이런걸 다운받아서 쓰라고 한다
github.com/googleads/googleads-mobile-unity/releases/tag/v5.4.0
Release Google Mobile Ads Unity Plugin v5.4.0 · googleads/googleads-mobile-unity
Release Notes: Add support for iOS14 with Google's SKAdNetwork identifiers automatically included in Info.plist. Added the RewardedInterstitialAd format. This feature is currently in private beta....
github.com
여기서 유니티 패키지를 다운받아서 푼다
유니티 버전은 2019.4.1f1이랑 2019.4.31f1사용했다
그리고 리졸브를 한다
누르고 생기는 스크립트오브젝트에 애드몹 코드를 입력한다
없으면 하단의 샘플코드를 넣는다
ca-app-pub-3940256099942544~3347511713
키가 이상하면 강종당하니 조심하자
애드몹 코드는 애드몹사이트에서 여기에 숨겨져있다
~가 들어간 코드여야 한다
전면광고방법
developers.google.com/admob/unity/interstitial?hl=ko
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
public class AdMobLoader : MonoBehaviour
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-3940256099942544/1033173712";
#elif UNITY_IOS
string adUnitId = "ca-app-pub-3940256099942544/4411468910";
#else
string adUnitId = "unexpected_platform";
#endif
public void Start()
{
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(initStatus => { });
RequestInterstitial();
}
public void Update()
{
}
private InterstitialAd interstitial;
private void RequestInterstitial()
{
// Initialize an InterstitialAd.
interstitial = new InterstitialAd(adUnitId);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
interstitial.OnAdLoaded += HandleOnAdLoaded;
// Load the interstitial with the request.
interstitial.LoadAd(request);
// Called when an ad request has successfully loaded.
}
public float timer = 5f; //5초뒤 광고표시
public void HandleOnAdLoaded(object sender, System.EventArgs args)
{
MonoBehaviour.print("HandleAdLoaded event received");
//로드끝나면 timer만큼 지난뒤 광고표시
Invoke(nameof(ShowInterstitial), timer);
}
void ShowInterstitial()
{
Debug.Log("광고가 표시됨");
if (interstitial.IsLoaded())
{
interstitial.Show();
}
}
private void InterstitialDestroy()
{
interstitial.Destroy();
}
}
기본 샘플코드를 이용하여 만들어봤다
print같은 이상한 코드가 있지만 귀찮으니 안 고쳤다
코드위치는 여기고 /가 들어간 코드여야 한다
끝
'Unity' 카테고리의 다른 글
유니티 동영상 촬영, 스크린샷 캡쳐 (0) | 2021.03.18 |
---|---|
유니티 카드보드 VR 사용법 (0) | 2021.02.28 |
VRM 파일 만들기 (0) | 2021.02.25 |