From 6cfaecf0f711ffd9fb8ddbe5802e8d9d5e2edde4 Mon Sep 17 00:00:00 2001 From: Ino Date: Fri, 7 Nov 2025 09:01:16 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B5=AC=EA=B8=80=20=EC=95=A0=EB=93=9C?= =?UTF-8?q?=EB=AA=B9=20=EB=AF=B8=EB=94=94=EC=97=90=EC=9D=B4=EC=85=98=20->?= =?UTF-8?q?=20=EC=9C=A0=EB=8B=88=ED=8B=B0=20=EA=B4=91=EA=B3=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Plugins/Android/mainTemplate.gradle | 1 + .../Plugins/Android/settingsTemplate.gradle | 2 +- Assets/Resources/VersionCode.txt | 2 +- Assets/Scripts/AttachToGameObject/ADInfo.cs | 286 ++++++------------ Assets/SheGotWet_Memo.txt | 13 - Packages/manifest.json | 1 + Packages/packages-lock.json | 10 + .../AndroidResolverDependencies.xml | 1 + ProjectSettings/ProjectSettings.asset | 2 +- 9 files changed, 108 insertions(+), 210 deletions(-) diff --git a/Assets/Plugins/Android/mainTemplate.gradle b/Assets/Plugins/Android/mainTemplate.gradle index 7b9490e..9e76273 100644 --- a/Assets/Plugins/Android/mainTemplate.gradle +++ b/Assets/Plugins/Android/mainTemplate.gradle @@ -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**} diff --git a/Assets/Plugins/Android/settingsTemplate.gradle b/Assets/Plugins/Android/settingsTemplate.gradle index 9972b15..693a62b 100644 --- a/Assets/Plugins/Android/settingsTemplate.gradle +++ b/Assets/Plugins/Android/settingsTemplate.gradle @@ -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 diff --git a/Assets/Resources/VersionCode.txt b/Assets/Resources/VersionCode.txt index 301160a..f11c82a 100644 --- a/Assets/Resources/VersionCode.txt +++ b/Assets/Resources/VersionCode.txt @@ -1 +1 @@ -8 \ No newline at end of file +9 \ No newline at end of file diff --git a/Assets/Scripts/AttachToGameObject/ADInfo.cs b/Assets/Scripts/AttachToGameObject/ADInfo.cs index 62fd47c..975d2dc 100644 --- a/Assets/Scripts/AttachToGameObject/ADInfo.cs +++ b/Assets/Scripts/AttachToGameObject/ADInfo.cs @@ -1,205 +1,80 @@ -using GoogleMobileAds.Api; using System; using UnityEngine; +using UnityEngine.Advertisements; -public class ADInfo : MonoBehaviourSingletonTemplate +public class ADInfo : MonoBehaviourSingletonTemplate, + IUnityAdsInitializationListener, IUnityAdsLoadListener, IUnityAdsShowListener { - //[RuntimeInitializeOnLoadMethod] - //static void OnRuntimeMethodLoad() { new GameObject("ADInfo").AddComponent(); } +#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 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 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 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()) + Advertisement.Load(placement_Interstitial, this); + } + else + { + Advertisement.Load(placement_Rewarded, this); + } + } + + public void Set_Banner(bool active) + { + return; + + if (active) + { + if (!SaveMgr.Ins.Get_ShopNoAD()) { - m_interstitialAd.Show(); - } - else - { - GetReward = 2; - Load_InterstitialAd(InterstitialAd_ID, Set_InterstitialAd); + 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 { - if (long_rewardedAd != null && long_rewardedAd.CanShowAd()) - { - long_rewardedAd.Show((Reward reward) => - { - GetReward = 1; - Load_LongAD(longAD, Set_LongAD); - }); - } - else - { - GetReward = 2; - Load_LongAD(longAD, Set_LongAD); - } + Advertisement.Banner.Hide(); } } @@ -211,14 +86,9 @@ public class ADInfo : MonoBehaviourSingletonTemplate 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 } } - 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; - - if (active) - { - //// 배너 광고 요청 및 표시 - //var adRequest = new AdRequest(); - //_bannerView.LoadAd(adRequest); - if (!SaveMgr.Ins.Get_ShopNoAD()) - _bannerView.Show(); - } - else - { - _bannerView.Hide(); - } + Debug.Log("Unity Ads Initialization Complete"); } + + public void OnInitializationFailed(UnityAdsInitializationError error, string message) + { + 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) + { + Debug.LogError($"Show failed {placementId}: {error} - {message}"); + GetReward = 2; + } + + public void OnUnityAdsShowStart(string placementId) { } + public void OnUnityAdsShowClick(string placementId) { } } \ No newline at end of file diff --git a/Assets/SheGotWet_Memo.txt b/Assets/SheGotWet_Memo.txt index 361036a..e69de29 100644 --- a/Assets/SheGotWet_Memo.txt +++ b/Assets/SheGotWet_Memo.txt @@ -1,13 +0,0 @@ -게등위 버전 - - -게등위 이후 라이브 버전 - - 게등위 테스트 제거 - - 뽑기 연출 개선 - -- 라이트 추가 - -- 뽑기 상자 여러 개가 랜덤하게 나왔으면... - - 럭키 뽑기 게임 개선 - -- 컵 안에 구슬 보이기 - -- 컵을 기울였다 다시 세웠다 할 수 있게 - -- 리필 - - 파이어 베이스 \ No newline at end of file diff --git a/Packages/manifest.json b/Packages/manifest.json index 387adb4..18d2230 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -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", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index c08c8d8..1b4e486 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -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, diff --git a/ProjectSettings/AndroidResolverDependencies.xml b/ProjectSettings/AndroidResolverDependencies.xml index 6c49a70..33fe8bb 100644 --- a/ProjectSettings/AndroidResolverDependencies.xml +++ b/ProjectSettings/AndroidResolverDependencies.xml @@ -6,6 +6,7 @@ com.google.android.ump:user-messaging-platform:3.1.0 com.onestorecorp.sdk:sdk-iap:21.02.01 com.onestorecorp.sdk:sdk-licensing:2.2.1 + com.unity3d.ads:unity-ads:[4.16.3,4.17[ com.unity3d.ads:unity-ads:4.12.3 diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 6ec1d01..8e358bd 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -173,7 +173,7 @@ PlayerSettings: iPhone: 0 tvOS: 0 overrideDefaultApplicationIdentifier: 1 - AndroidBundleVersionCode: 8 + AndroidBundleVersionCode: 9 AndroidMinSdkVersion: 24 AndroidTargetSdkVersion: 35 AndroidPreferredInstallLocation: 1