Compare commits
No commits in common. "68ddcea9f2137af647c0ce1cd85125a0de30d0d1" and "b9fe36c2e07cdc26df9120fcf73746595567d410" have entirely different histories.
68ddcea9f2
...
b9fe36c2e0
|
|
@ -29,7 +29,6 @@ namespace WZ
|
|||
Action<AdValue> OnAdPaid,
|
||||
Action<string,string,double> onAdClicked)
|
||||
{
|
||||
if (string.IsNullOrEmpty(adUnitId)) return;
|
||||
if (_bannerAds.ContainsKey(adUnitId))
|
||||
{
|
||||
LoggerUtils.Debug($"Bigo banner Ad unit {adUnitId} already exists");
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ namespace WZ
|
|||
Action<AdValue> onAdPaid,
|
||||
Action<string,string,double> onAdClicked)
|
||||
{
|
||||
if (string.IsNullOrEmpty(adUnitId)) return;
|
||||
if (_interstitialAds.ContainsKey(adUnitId))
|
||||
{
|
||||
LoggerUtils.Debug($"[Admob] Interstitial Ad unit {adUnitId} already exists");
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ namespace WZ
|
|||
|
||||
private void CreateNativeAd(string adUnitId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(adUnitId)) return;
|
||||
if (_nativeAds.ContainsKey(adUnitId))
|
||||
{
|
||||
LoggerUtils.Debug($"[Admob] Native Ad unit {adUnitId} already exists");
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ namespace WZ
|
|||
Action<bool> onEarnRewarded,
|
||||
Action<string,string,double> onAdClicked)
|
||||
{
|
||||
if (string.IsNullOrEmpty(adUnitId)) return;
|
||||
if (_rewardedAds.ContainsKey(adUnitId))
|
||||
{
|
||||
LoggerUtils.Debug($"[Admob] rewarded Ad unit {adUnitId} already exists");
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ namespace WZ
|
|||
Action<AdValue> onAdPaid,
|
||||
Action<string,string,double> onAdClicked)
|
||||
{
|
||||
if (string.IsNullOrEmpty(adUnitId)) return;
|
||||
if (_appOpenAds.ContainsKey(adUnitId))
|
||||
{
|
||||
LoggerUtils.Debug($"[Admob] appopen Ad unit {adUnitId} already exists");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace WZ
|
||||
|
|
@ -9,7 +9,6 @@ namespace WZ
|
|||
public static class AdConfigParser
|
||||
{
|
||||
private static AdConfig _config;
|
||||
private static Dictionary<string,object> _configDict = new Dictionary<string, object>();
|
||||
public static AdConfig Parse(string json)
|
||||
{
|
||||
try
|
||||
|
|
@ -23,7 +22,6 @@ namespace WZ
|
|||
|
||||
// 使用 JsonUtility 解析 JSON
|
||||
_config = JsonUtility.FromJson<AdConfig>(json);
|
||||
_configDict = JsonToDictionary(json);
|
||||
|
||||
if (_config == null)
|
||||
{
|
||||
|
|
@ -41,12 +39,6 @@ namespace WZ
|
|||
}
|
||||
}
|
||||
|
||||
public static Dictionary<string,object> JsonToDictionary(string jsonStr)
|
||||
{
|
||||
Dictionary<string,object> dic= JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonStr);
|
||||
return dic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取 Admob 广告单元ID
|
||||
/// </summary>
|
||||
|
|
@ -64,62 +56,16 @@ namespace WZ
|
|||
_ => new List<string>()
|
||||
};
|
||||
}
|
||||
|
||||
switch (adType)
|
||||
|
||||
return adType switch
|
||||
{
|
||||
case AdsType.Banner:
|
||||
if (_configDict.ContainsKey("admob_banner_units"))
|
||||
{
|
||||
return _config.admob_banner_units ?? new List<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<string>{ StaticValue.AdmobNormalBannerId };
|
||||
}
|
||||
case AdsType.Rewarded:
|
||||
if (_configDict.ContainsKey("admob_rewarded_units"))
|
||||
{
|
||||
return _config.admob_rewarded_units ?? new List<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<string>{ StaticValue.AdmobRewardId };
|
||||
}
|
||||
case AdsType.Native:
|
||||
if (_configDict.ContainsKey("admob_native_units"))
|
||||
{
|
||||
return _config.admob_native_units ?? new List<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<string>{ StaticValue.AdmobNativeId,
|
||||
StaticValue.AdmobMinddleNativeId,
|
||||
StaticValue.AdmobSmallNativeId,
|
||||
StaticValue.AdmobFullNativeId };
|
||||
}
|
||||
case AdsType.Splash:
|
||||
if (_configDict.ContainsKey("admob_splash_units"))
|
||||
{
|
||||
return _config.admob_splash_units ?? new List<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<string>{ StaticValue.AdmobSplashId };
|
||||
}
|
||||
case AdsType.Interstitial:
|
||||
if (_configDict.ContainsKey("admob_interstitial_units"))
|
||||
{
|
||||
return _config.admob_interstitial_units ?? new List<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<string>{ StaticValue.AdmobInterId };
|
||||
}
|
||||
default:
|
||||
return new List<string>();
|
||||
|
||||
|
||||
}
|
||||
AdsType.Interstitial => _config.admob_interstitial_units ?? new List<string>(),
|
||||
AdsType.Splash => _config.admob_splash_units ?? new List<string>(),
|
||||
AdsType.Rewarded => _config.admob_rewarded_units ?? new List<string>(),
|
||||
AdsType.Banner => _config.admob_banner_units ?? new List<string>(),
|
||||
AdsType.Native => _config.admob_native_units ?? new List<string>(),
|
||||
_ => new List<string>()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -137,29 +83,15 @@ namespace WZ
|
|||
};
|
||||
}
|
||||
|
||||
switch (adType)
|
||||
return adType switch
|
||||
{
|
||||
case AdsType.Interstitial:
|
||||
if (_configDict.ContainsKey("topon_interstitial_units"))
|
||||
{
|
||||
return _config.topon_interstitial_units ?? new List<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<string>{ StaticValue.TopOnInterAdUnitID };
|
||||
}
|
||||
case AdsType.Rewarded:
|
||||
if (_configDict.ContainsKey("topon_rewarded_units"))
|
||||
{
|
||||
return _config.topon_rewarded_units ?? new List<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<string>{ StaticValue.TopOnRewardAdUnitID };;
|
||||
}
|
||||
default:
|
||||
return new List<string>();
|
||||
}
|
||||
AdsType.Interstitial => _config.topon_interstitial_units ?? new List<string>(),
|
||||
AdsType.Splash => _config.topon_splash_units ?? new List<string>(),
|
||||
AdsType.Rewarded => _config.topon_rewarded_units ?? new List<string>(),
|
||||
AdsType.Banner => _config.topon_banner_units ?? new List<string>(),
|
||||
AdsType.Native => _config.topon_native_units ?? new List<string>(),
|
||||
_ => new List<string>()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -177,30 +109,17 @@ namespace WZ
|
|||
};
|
||||
}
|
||||
|
||||
switch (adType)
|
||||
|
||||
return adType switch
|
||||
{
|
||||
case AdsType.Interstitial:
|
||||
if (_configDict.ContainsKey("max_interstitial_units"))
|
||||
{
|
||||
return _config.max_interstitial_units ?? new List<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<string>{ StaticValue.InterAdUnitID };
|
||||
}
|
||||
|
||||
case AdsType.Rewarded:
|
||||
if (_configDict.ContainsKey("max_rewarded_units"))
|
||||
{
|
||||
return _config.max_rewarded_units ?? new List<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<string>{ StaticValue.RewardAdUnitID };
|
||||
}
|
||||
default:
|
||||
return new List<string>();
|
||||
}
|
||||
AdsType.Interstitial => _config.max_interstitial_units ?? new List<string>(),
|
||||
AdsType.Splash => _config.max_splash_units ?? new List<string>(),
|
||||
AdsType.Rewarded => _config.max_rewarded_units ?? new List<string>(),
|
||||
AdsType.Banner => _config.max_banner_units ?? new List<string>(),
|
||||
AdsType.Native => _config.max_native_units ?? new List<string>(),
|
||||
_ => new List<string>()
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -232,39 +151,23 @@ namespace WZ
|
|||
_ => new List<string>()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取 TopOn App ID
|
||||
/// </summary>
|
||||
public static string GetTopOnAppId()
|
||||
{
|
||||
if (_config == null) return StaticValue.TopOnAppID;
|
||||
if (_configDict.ContainsKey("topon_app_id"))
|
||||
{
|
||||
return _config?.topon_app_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return StaticValue.TopOnAppID;
|
||||
}
|
||||
|
||||
return _config?.topon_app_id;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取 TopOn App Key
|
||||
/// </summary>
|
||||
public static string GetTopOnAppKey()
|
||||
{
|
||||
if (_config == null) return StaticValue.TopOnAppKey;
|
||||
|
||||
if (_configDict.ContainsKey("topon_app_key"))
|
||||
{
|
||||
return _config?.topon_app_key;
|
||||
}
|
||||
else
|
||||
{
|
||||
return StaticValue.TopOnAppKey;
|
||||
}
|
||||
return _config?.topon_app_key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue