구글 애드몹 미디에이션 -> 유니티 광고
This commit is contained in:
parent
92041f76df
commit
6cfaecf0f7
|
|
@ -11,6 +11,7 @@ dependencies {
|
|||
implementation 'com.google.android.ump:user-messaging-platform:3.1.0' // Assets/GoogleMobileAds/Editor/GoogleUmpDependencies.xml:7
|
||||
implementation 'com.onestorecorp.sdk:sdk-iap:21.02.01' // Assets/OneStoreCorpPlugins/Purchase/Editor/PurchaseDependencies.xml:6
|
||||
implementation 'com.onestorecorp.sdk:sdk-licensing:2.2.1' // Assets/OneStoreCorpPlugins/AppLicenseChecker/Editor/AppLicenseCheckerDependencies.xml:6
|
||||
// implementation 'com.unity3d.ads:unity-ads:[4.16.3,4.17[' // Packages/com.unity.ads/Editor/Source/Dependencies.xml:7
|
||||
implementation 'com.unity3d.ads:unity-ads:4.12.3' // Assets/GoogleMobileAds/Mediation/UnityAds/Editor/UnityMediationDependencies.xml:33
|
||||
// Android Resolver Dependencies End
|
||||
**DEPS**}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ dependencyResolutionManagement {
|
|||
url "https://repo.onestore.net/repository/onestore-sdk-public" // Assets/OneStoreCorpPlugins/AppLicenseChecker/Editor/AppLicenseCheckerDependencies.xml:5, Assets/OneStoreCorpPlugins/Purchase/Editor/PurchaseDependencies.xml:5
|
||||
}
|
||||
maven {
|
||||
url "https://maven.google.com/" // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7, Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:12, Assets/GoogleMobileAds/Editor/GoogleUmpDependencies.xml:7
|
||||
url "https://maven.google.com/" // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7, Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:12, Assets/GoogleMobileAds/Editor/GoogleUmpDependencies.xml:7, Packages/com.unity.ads/Editor/Source/Dependencies.xml:7
|
||||
}
|
||||
maven {
|
||||
url "https://repo.maven.apache.org/maven2/" // Assets/GoogleMobileAds/Mediation/UnityAds/Editor/UnityMediationDependencies.xml:25, Assets/GoogleMobileAds/Mediation/UnityAds/Editor/UnityMediationDependencies.xml:33
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
8
|
||||
9
|
||||
|
|
@ -1,205 +1,80 @@
|
|||
using GoogleMobileAds.Api;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Advertisements;
|
||||
|
||||
public class ADInfo : MonoBehaviourSingletonTemplate<ADInfo>
|
||||
public class ADInfo : MonoBehaviourSingletonTemplate<ADInfo>,
|
||||
IUnityAdsInitializationListener, IUnityAdsLoadListener, IUnityAdsShowListener
|
||||
{
|
||||
//[RuntimeInitializeOnLoadMethod]
|
||||
//static void OnRuntimeMethodLoad() { new GameObject("ADInfo").AddComponent<ADInfo>(); }
|
||||
#if UNITY_ANDROID
|
||||
string gameId = "5947579";
|
||||
#elif UNITY_IOS
|
||||
string gameId = "5947578";
|
||||
#endif
|
||||
|
||||
//public static ADInfo Ins;
|
||||
bool testMode = false;
|
||||
|
||||
private RewardedInterstitialAd short_rewardedInterstitialAd;
|
||||
string rewardedInterstitialAd_ID = "ca-app-pub-6390804219581974/3468554834";
|
||||
//string rewardedInterstitialAd_ID = "ca-app-pub-3940256099942544/1033173712"; // 테스트
|
||||
|
||||
private InterstitialAd m_interstitialAd;
|
||||
string InterstitialAd_ID = "ca-app-pub-2550554896492831/9309815439";
|
||||
//string InterstitialAd_ID = "ca-app-pub-3940256099942544/1033173712"; // 테스트
|
||||
|
||||
private RewardedAd long_rewardedAd;
|
||||
string longAD = "ca-app-pub-2550554896492831/2536577422";
|
||||
//string longAD = "ca-app-pub-3940256099942544/5224354917"; // 테스트
|
||||
|
||||
BannerView _bannerView;
|
||||
string bannerAD = "ca-app-pub-2550554896492831/2225586237";
|
||||
//string bannerAD = "ca-app-pub-3940256099942544/6300978111"; // 테스트
|
||||
string placement_Interstitial = "Interstitial_Android";
|
||||
string placement_Rewarded = "Rewarded_Android";
|
||||
string placement_Banner = "Banner_Android";
|
||||
|
||||
byte GetReward = 0;
|
||||
Action Action_success, Action_fail;
|
||||
bool isLoading_InterstitialAd, isLoading_RewardedAd;
|
||||
float curVolume;
|
||||
|
||||
//private void Awake()
|
||||
//{
|
||||
// Ins = this;
|
||||
// DontDestroyOnLoad(gameObject);
|
||||
//}
|
||||
|
||||
public void Start()
|
||||
void Start()
|
||||
{
|
||||
MobileAds.Initialize(initStatus =>
|
||||
{
|
||||
//Load_RewardedInterstitialAd(rewardedInterstitialAd_ID, Set_RewardedInterstitialAd);
|
||||
Load_InterstitialAd(InterstitialAd_ID, Set_InterstitialAd);
|
||||
Load_LongAD(longAD, Set_LongAD);
|
||||
|
||||
AdSize adaptiveSize = AdSize.GetPortraitAnchoredAdaptiveBannerAdSizeWithWidth(AdSize.FullWidth);
|
||||
_bannerView = new BannerView(bannerAD, adaptiveSize, AdPosition.Bottom);
|
||||
});
|
||||
}
|
||||
|
||||
void Set_RewardedInterstitialAd(RewardedInterstitialAd ad)
|
||||
{
|
||||
if (short_rewardedInterstitialAd != null)
|
||||
{
|
||||
short_rewardedInterstitialAd.Destroy();
|
||||
short_rewardedInterstitialAd = null;
|
||||
}
|
||||
short_rewardedInterstitialAd = ad;
|
||||
}
|
||||
void Set_InterstitialAd(InterstitialAd ad)
|
||||
{
|
||||
if (m_interstitialAd != null)
|
||||
{
|
||||
m_interstitialAd.Destroy();
|
||||
m_interstitialAd = null;
|
||||
}
|
||||
|
||||
m_interstitialAd = ad;
|
||||
|
||||
m_interstitialAd.OnAdFullScreenContentClosed += () =>
|
||||
{
|
||||
GetReward = 1;
|
||||
Load_InterstitialAd(InterstitialAd_ID, Set_InterstitialAd);
|
||||
};
|
||||
|
||||
m_interstitialAd.OnAdFullScreenContentFailed += (AdError adError) =>
|
||||
{
|
||||
Load_InterstitialAd(InterstitialAd_ID, Set_InterstitialAd);
|
||||
};
|
||||
}
|
||||
void Set_LongAD(RewardedAd ad)
|
||||
{
|
||||
if (long_rewardedAd != null)
|
||||
{
|
||||
long_rewardedAd.Destroy();
|
||||
long_rewardedAd = null;
|
||||
}
|
||||
long_rewardedAd = ad;
|
||||
}
|
||||
|
||||
void Load_RewardedInterstitialAd(string s_ad, Action<RewardedInterstitialAd> adaction)
|
||||
{
|
||||
// create our request used to load the ad.
|
||||
var adRequest = new AdRequest();
|
||||
|
||||
// send the request to load the ad.
|
||||
RewardedInterstitialAd.Load(s_ad, adRequest,
|
||||
(RewardedInterstitialAd ad, LoadAdError error) =>
|
||||
{
|
||||
// if error is not null, the load request failed.
|
||||
if (error != null || ad == null)
|
||||
{
|
||||
Debug.LogError("Rewarded ad failed to load an ad " +
|
||||
"with error : " + error);
|
||||
return;
|
||||
}
|
||||
|
||||
adaction(ad);
|
||||
});
|
||||
}
|
||||
void Load_InterstitialAd(string s_ad, Action<InterstitialAd> adaction)
|
||||
{
|
||||
if (isLoading_InterstitialAd) return;
|
||||
isLoading_InterstitialAd = true;
|
||||
|
||||
// create our request used to load the ad.
|
||||
var adRequest = new AdRequest();
|
||||
|
||||
// send the request to load the ad.
|
||||
InterstitialAd.Load(s_ad, adRequest,
|
||||
(InterstitialAd ad, LoadAdError error) =>
|
||||
{
|
||||
isLoading_InterstitialAd = false;
|
||||
|
||||
// if error is not null, the load request failed.
|
||||
if (error != null || ad == null)
|
||||
{
|
||||
Debug.LogError("Rewarded ad failed to load an ad " +
|
||||
"with error : " + error);
|
||||
return;
|
||||
}
|
||||
|
||||
adaction(ad);
|
||||
});
|
||||
}
|
||||
void Load_LongAD(string s_ad, Action<RewardedAd> adaction)
|
||||
{
|
||||
if (isLoading_RewardedAd) return;
|
||||
isLoading_RewardedAd = true;
|
||||
|
||||
// create our request used to load the ad.
|
||||
var adRequest = new AdRequest();
|
||||
|
||||
// send the request to load the ad.
|
||||
RewardedAd.Load(s_ad, adRequest,
|
||||
(RewardedAd ad, LoadAdError error) =>
|
||||
{
|
||||
isLoading_RewardedAd = false;
|
||||
|
||||
// if error is not null, the load request failed.
|
||||
if (error != null || ad == null)
|
||||
{
|
||||
Debug.LogError("Rewarded ad failed to load an ad " +
|
||||
"with error : " + error);
|
||||
return;
|
||||
}
|
||||
|
||||
adaction(ad);
|
||||
});
|
||||
Advertisement.Initialize(gameId, testMode, this);
|
||||
}
|
||||
|
||||
public void Show_AD(bool bshort, Action _success, Action _fail = null)
|
||||
{
|
||||
Stop_Game();
|
||||
|
||||
Action_success = _success;
|
||||
Action_fail = _fail;
|
||||
GetReward = 0;
|
||||
|
||||
if (bshort)
|
||||
{
|
||||
if (SaveMgr.Ins.Get_ShopNoAD()) // 리워드형 광고가 아니면 제거
|
||||
if (SaveMgr.Ins.Get_ShopNoAD())
|
||||
{
|
||||
GetReward = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_interstitialAd != null && m_interstitialAd.CanShowAd())
|
||||
{
|
||||
m_interstitialAd.Show();
|
||||
Advertisement.Load(placement_Interstitial, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetReward = 2;
|
||||
Load_InterstitialAd(InterstitialAd_ID, Set_InterstitialAd);
|
||||
Advertisement.Load(placement_Rewarded, this);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
public void Set_Banner(bool active)
|
||||
{
|
||||
if (long_rewardedAd != null && long_rewardedAd.CanShowAd())
|
||||
return;
|
||||
|
||||
if (active)
|
||||
{
|
||||
long_rewardedAd.Show((Reward reward) =>
|
||||
if (!SaveMgr.Ins.Get_ShopNoAD())
|
||||
{
|
||||
GetReward = 1;
|
||||
Load_LongAD(longAD, Set_LongAD);
|
||||
Advertisement.Banner.Load(placement_Banner, new BannerLoadOptions
|
||||
{
|
||||
loadCallback = () =>
|
||||
{
|
||||
Debug.Log("Banner Load Success");
|
||||
Advertisement.Banner.SetPosition(BannerPosition.BOTTOM_CENTER);
|
||||
Advertisement.Banner.Show(placement_Banner);
|
||||
},
|
||||
errorCallback = (err) =>
|
||||
{
|
||||
Debug.Log("Banner Load Fail: " + err);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GetReward = 2;
|
||||
Load_LongAD(longAD, Set_LongAD);
|
||||
}
|
||||
Advertisement.Banner.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -211,14 +86,9 @@ public class ADInfo : MonoBehaviourSingletonTemplate<ADInfo>
|
|||
case 1:
|
||||
GetReward = 0;
|
||||
Play_Game();
|
||||
Action_success?.Invoke(); // 후 처리 및 저장
|
||||
Action_success?.Invoke();
|
||||
break;
|
||||
case 2:
|
||||
GetReward = 0;
|
||||
Play_Game();
|
||||
LobbyUI.Ins.m_ToastUI.Set("준비된 광고가 없습니다.\n나중에 다시 시도해 주세요.");
|
||||
Action_fail?.Invoke();
|
||||
break;
|
||||
case 3:
|
||||
GetReward = 0;
|
||||
Play_Game();
|
||||
|
|
@ -228,34 +98,62 @@ public class ADInfo : MonoBehaviourSingletonTemplate<ADInfo>
|
|||
}
|
||||
}
|
||||
|
||||
float curVolume;
|
||||
void Stop_Game()
|
||||
{
|
||||
//Time.timeScale = 0f;
|
||||
curVolume = AudioListener.volume;
|
||||
AudioListener.volume = 0f;
|
||||
}
|
||||
|
||||
void Play_Game()
|
||||
{
|
||||
//Time.timeScale = 1f;
|
||||
AudioListener.volume = curVolume;
|
||||
}
|
||||
|
||||
public void Set_Banner(bool active)
|
||||
// ===========================================================
|
||||
// IUnityAdsInitializationListener
|
||||
// ===========================================================
|
||||
public void OnInitializationComplete()
|
||||
{
|
||||
if (_bannerView == null) return;
|
||||
Debug.Log("Unity Ads Initialization Complete");
|
||||
}
|
||||
|
||||
if (active)
|
||||
public void OnInitializationFailed(UnityAdsInitializationError error, string message)
|
||||
{
|
||||
//// 배너 광고 요청 및 표시
|
||||
//var adRequest = new AdRequest();
|
||||
//_bannerView.LoadAd(adRequest);
|
||||
if (!SaveMgr.Ins.Get_ShopNoAD())
|
||||
_bannerView.Show();
|
||||
Debug.LogError($"Unity Ads Init Failed: {error} - {message}");
|
||||
}
|
||||
|
||||
// ===========================================================
|
||||
// IUnityAdsLoadListener
|
||||
// ===========================================================
|
||||
public void OnUnityAdsAdLoaded(string placementId)
|
||||
{
|
||||
Debug.Log("Ad Loaded: " + placementId);
|
||||
Advertisement.Show(placementId, this);
|
||||
}
|
||||
|
||||
public void OnUnityAdsFailedToLoad(string placementId, UnityAdsLoadError error, string message)
|
||||
{
|
||||
Debug.LogError($"Failed to load Ad {placementId}: {error} - {message}");
|
||||
GetReward = 2;
|
||||
}
|
||||
|
||||
// ===========================================================
|
||||
// IUnityAdsShowListener
|
||||
// ===========================================================
|
||||
public void OnUnityAdsShowComplete(string placementId, UnityAdsShowCompletionState showCompletionState)
|
||||
{
|
||||
if (placementId == placement_Rewarded && showCompletionState == UnityAdsShowCompletionState.COMPLETED)
|
||||
GetReward = 1;
|
||||
else
|
||||
GetReward = 2;
|
||||
}
|
||||
|
||||
public void OnUnityAdsShowFailure(string placementId, UnityAdsShowError error, string message)
|
||||
{
|
||||
_bannerView.Hide();
|
||||
}
|
||||
Debug.LogError($"Show failed {placementId}: {error} - {message}");
|
||||
GetReward = 2;
|
||||
}
|
||||
|
||||
public void OnUnityAdsShowStart(string placementId) { }
|
||||
public void OnUnityAdsShowClick(string placementId) { }
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
게등위 버전
|
||||
|
||||
|
||||
게등위 이후 라이브 버전
|
||||
- 게등위 테스트 제거
|
||||
- 뽑기 연출 개선
|
||||
-- 라이트 추가
|
||||
-- 뽑기 상자 여러 개가 랜덤하게 나왔으면...
|
||||
- 럭키 뽑기 게임 개선
|
||||
-- 컵 안에 구슬 보이기
|
||||
-- 컵을 기울였다 다시 세웠다 할 수 있게
|
||||
-- 리필
|
||||
- 파이어 베이스
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"com.unity.addressables": "2.7.3",
|
||||
"com.unity.ads": "4.16.3",
|
||||
"com.unity.collab-proxy": "2.9.3",
|
||||
"com.unity.feature.2d": "2.0.1",
|
||||
"com.unity.ide.rider": "3.0.38",
|
||||
|
|
|
|||
|
|
@ -108,6 +108,16 @@
|
|||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.ads": {
|
||||
"version": "4.16.3",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.ugui": "1.0.0",
|
||||
"com.unity.modules.androidjni": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.bindings.openimageio": {
|
||||
"version": "1.0.0",
|
||||
"depth": 1,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<package>com.google.android.ump:user-messaging-platform:3.1.0</package>
|
||||
<package>com.onestorecorp.sdk:sdk-iap:21.02.01</package>
|
||||
<package>com.onestorecorp.sdk:sdk-licensing:2.2.1</package>
|
||||
<package>com.unity3d.ads:unity-ads:[4.16.3,4.17[</package>
|
||||
<package>com.unity3d.ads:unity-ads:4.12.3</package>
|
||||
</packages>
|
||||
<files />
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ PlayerSettings:
|
|||
iPhone: 0
|
||||
tvOS: 0
|
||||
overrideDefaultApplicationIdentifier: 1
|
||||
AndroidBundleVersionCode: 8
|
||||
AndroidBundleVersionCode: 9
|
||||
AndroidMinSdkVersion: 24
|
||||
AndroidTargetSdkVersion: 35
|
||||
AndroidPreferredInstallLocation: 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue