From f4a1f2e1e2003fb2ea3345e000ac46dc1b47b048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=89=E5=B3=B0?= Date: Wed, 10 Sep 2025 16:42:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BF=80=E5=8A=B1=E3=80=81=E6=8F=92=E5=B1=8F?= =?UTF-8?q?=E3=80=81=E5=85=A8=E5=B1=8FNative=E7=AB=9E=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SDKManager/AdsSDKManager/AdsSDKManager.cs | 21 ++++-- .../AdsSDKManager/Utils/AdsBidResult.cs | 69 ++++++++++++++++++- Assets/Script/SDKManager/RushSDKManager.cs | 13 +++- Assets/Script/Test.cs | 1 + Assets/StreamingAssets/build_info | 2 +- 5 files changed, 99 insertions(+), 7 deletions(-) diff --git a/Assets/Script/SDKManager/AdsSDKManager/AdsSDKManager.cs b/Assets/Script/SDKManager/AdsSDKManager/AdsSDKManager.cs index cdc4758..5892c1b 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/AdsSDKManager.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/AdsSDKManager.cs @@ -117,14 +117,14 @@ namespace WZ { return BigoAdsManager.Instance.GetRewardedRevenue(); } - else if (result == PlatformType.Topon) - { - return TpnAdsManager.Instance.GetRewardedRevenue(); - } else if (result == PlatformType.Kwai) { return KwaiAdsManager.Instance.GetRewardedRevenue(); } + else if (result == PlatformType.Topon) + { + return TpnAdsManager.Instance.GetRewardedRevenue(); + } else { return -1; @@ -314,6 +314,19 @@ namespace WZ return AdsBidResult.GetPlatformType(priceInfo); } } + + /// + /// 广告比价类型 + /// + /// + public AdsType GetAdBidType() + { + var adsType = AdsBidResult.GetAdsType(TpnAdsManager.Instance._topon_rewarded_units, TpnAdsManager.Instance._topon_interstitial_units, GetRewardedAdRevenue(), GetInterstitialAdRevenue(), RushSDKManager.Instance.GetFullNativeRevenue()); + LoggerUtils.Debug($"[SDK] AdBidType: {adsType} "); + return adsType; + } + + #region IvRules diff --git a/Assets/Script/SDKManager/AdsSDKManager/Utils/AdsBidResult.cs b/Assets/Script/SDKManager/AdsSDKManager/Utils/AdsBidResult.cs index c0104c3..fca23bc 100644 --- a/Assets/Script/SDKManager/AdsSDKManager/Utils/AdsBidResult.cs +++ b/Assets/Script/SDKManager/AdsSDKManager/Utils/AdsBidResult.cs @@ -22,6 +22,7 @@ namespace WZ ToponAdUnitId = toponAdUnitId; } } + public static class AdsBidResult { private static object m_toponObj = "m_toponObj"; @@ -29,9 +30,16 @@ namespace WZ private static object m_admobObj = "m_admobObj"; private static object m_bigoObj = "m_bigoObj"; private static object m_kwaiObj = "m_kwaiObj"; + + private static object m_toponRewardObj = "m_toponRewardObj"; + private static object m_toponInterstitialObj = "m_toponInterstitialObj"; + private static object m_rewardObj = "m_rewardObj"; + private static object m_interstitialObj = "m_interstitialObj"; + private static object m_fullNativeObj = "m_fullNativeObj"; + public static PlatformType GetPlatformType(AdPriceInfo priceInfo) { -#if UNITY_ANDROID && !UNITY_EDITOR + #if UNITY_ANDROID && !UNITY_EDITOR using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { AndroidJavaObject activity = unityPlayer.GetStatic("currentActivity"); @@ -86,5 +94,64 @@ namespace WZ return PlatformType.NULL; #endif } + + public static AdsType GetAdsType(string toponRewardAdUnitId, string topinInterstitialAdUnitId, double rewardPrice, double interstitialPrice, double fullNativePrice) + { +#if UNITY_ANDROID && !UNITY_EDITOR + using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) + { + AndroidJavaObject activity = unityPlayer.GetStatic("currentActivity"); + AndroidJavaObject toponRewardCustomContentInfo = new AndroidJavaObject("com.thinkup.core.api.TUCustomContentInfo", toponRewardAdUnitId, m_toponRewardObj); + AndroidJavaObject toponInterstitialCustomContentInfo = new AndroidJavaObject("com.thinkup.core.api.TUCustomContentInfo", topinInterstitialAdUnitId, m_toponInterstitialObj); + AndroidJavaObject rewardCustomContentInfo = new AndroidJavaObject("com.thinkup.core.api.TUCustomContentInfo", rewardPrice * 1000, m_rewardObj); + AndroidJavaObject interstitialCustomContentInfo = new AndroidJavaObject("com.thinkup.core.api.TUCustomContentInfo", interstitialPrice * 1000, m_interstitialObj); + AndroidJavaObject fullNativeCustomContentInfo = new AndroidJavaObject("com.thinkup.core.api.TUCustomContentInfo", fullNativePrice * 1000, m_fullNativeObj); + + AndroidJavaObject atCustomContentInfoList = new AndroidJavaObject("java.util.ArrayList"); + atCustomContentInfoList.Call("add", toponRewardCustomContentInfo); + atCustomContentInfoList.Call("add", toponInterstitialCustomContentInfo); + atCustomContentInfoList.Call("add", rewardCustomContentInfo); + atCustomContentInfoList.Call("add", interstitialCustomContentInfo); + atCustomContentInfoList.Call("add", fullNativeCustomContentInfo); + AndroidJavaClass sdkGlobalSetting = new AndroidJavaClass("com.thinkup.core.api.TUSDKGlobalSetting"); + AndroidJavaObject maxPriceCustomContentInfo = sdkGlobalSetting.CallStatic("customContentReviewResult", atCustomContentInfoList); + + string customContentString = maxPriceCustomContentInfo.Get("customContentString"); + double customContentDouble = maxPriceCustomContentInfo.Get("customContentDouble"); + AndroidJavaObject customContentObject = maxPriceCustomContentInfo.Get("customContentObject"); + + string customContentObjectString = customContentObject != null ? customContentObject.Call("toString") : "null"; + LoggerUtils.Debug("[AdsBidResult] rewardPrice: " + rewardPrice * 1000 + " interstitialPrice: " + interstitialPrice * 1000 + " fullNativePrice: " + fullNativePrice * 1000 + " toponRewardAdUnitId: " +toponRewardAdUnitId + " topinInterstitialAdUnitId: " + topinInterstitialAdUnitId); + LoggerUtils.Debug("[AdsBidResult] final maxPriceCustomContentInfo: " + customContentString + " double: " + customContentDouble + " object:" + customContentObjectString); + if (customContentObjectString.Equals(m_toponRewardObj)) + { + return AdsType.Rewarded; + } + else if (customContentObjectString.Equals(m_toponInterstitialObj)) + { + return AdsType.Interstitial; + } + else if (customContentObjectString.Equals(m_rewardObj)) + { + return AdsType.Rewarded; + } + else if (customContentObjectString.Equals(m_interstitialObj)) + { + return AdsType.Interstitial; + } + else if (customContentObjectString.Equals(m_fullNativeObj)) + { + return AdsType.Native; + } + else + { + return AdsType.Rewarded; + } + } +#else + return AdsType.Rewarded; +#endif + + } } } \ No newline at end of file diff --git a/Assets/Script/SDKManager/RushSDKManager.cs b/Assets/Script/SDKManager/RushSDKManager.cs index 08ccbaf..d4ee755 100644 --- a/Assets/Script/SDKManager/RushSDKManager.cs +++ b/Assets/Script/SDKManager/RushSDKManager.cs @@ -31,6 +31,15 @@ public class RushSDKManager : D_MonoSingleton #region ad + /// + /// 多类型广告竞价:激励、插屏、全屏Native + /// + /// + public AdsType GetAdBidType() + { + return AdsSDKManager.Instance.GetAdBidType(); + } + /// /// 是否已缓存激励广告 /// @@ -86,6 +95,8 @@ public class RushSDKManager : D_MonoSingleton return AdsSDKManager.Instance.GetRewardedAdRevenue(); } + + /// /// 是否已缓存插屏 /// @@ -193,7 +204,7 @@ public class RushSDKManager : D_MonoSingleton /// - /// 获取激励广告价值 + /// 获取全屏Native广告价值 /// /// public double GetFullNativeRevenue() diff --git a/Assets/Script/Test.cs b/Assets/Script/Test.cs index fbb0dca..d336252 100644 --- a/Assets/Script/Test.cs +++ b/Assets/Script/Test.cs @@ -17,6 +17,7 @@ public class Test : MonoBehaviour { small = gameObject.transform.Find("NativeAd-small").GetComponent(); medium = gameObject.transform.Find("NativeAd-medium").GetComponent(); + RushSDKManager.Instance.InitializeSdk(null, true); } public void OnShowAd() diff --git a/Assets/StreamingAssets/build_info b/Assets/StreamingAssets/build_info index a3e623d..0de6e8a 100644 --- a/Assets/StreamingAssets/build_info +++ b/Assets/StreamingAssets/build_info @@ -1 +1 @@ -Build from HY-LSZNWIN10 at 2025/9/9 14:28:41 \ No newline at end of file +Build from HY-LSZNWIN10 at 2025/9/10 16:37:43 \ No newline at end of file