You've already forked CC-Framework.Commercialization
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 915180881d | |||
| b56b47912e | |||
| 957c4e4045 | |||
| 377a279ac3 | |||
| b53846c98f | |||
| 89f5f66322 |
26
CHANGELOG.md
26
CHANGELOG.md
@@ -1,3 +1,29 @@
|
|||||||
|
# [1.0.14]
|
||||||
|
|
||||||
|
### 修复
|
||||||
|
|
||||||
|
* `AsyncAdPlayer` 增加展示确认阶段和统一失败收口,避免 `show` 发起后无回调时主链失联。
|
||||||
|
* 抽象播放器补充展示超时配置与内部展示开始通知,保持外部调用接口不变。
|
||||||
|
* 清理广告源级失败对主链的误接线,避免 `AdSource` 过程回调误判为最终失败。
|
||||||
|
|
||||||
|
# [1.0.13]
|
||||||
|
|
||||||
|
### 修复
|
||||||
|
|
||||||
|
* 修复插屏成功关闭时误触发 `GLOBAL_ShowAwardVideoComplete` 全局奖励视频完成事件的问题。
|
||||||
|
|
||||||
|
# [1.0.12]
|
||||||
|
|
||||||
|
### 新增
|
||||||
|
|
||||||
|
* `ADManager` 新增 `EnterAdScenario(AD_Type, string)`,支持应用层显式上报广告场景到达。
|
||||||
|
* `ADPlayer` 增加预热、重试和播放前钩子能力,用于平台层策略化调度。
|
||||||
|
|
||||||
|
### 修复
|
||||||
|
|
||||||
|
* `AsyncAdPlayer` 增强首播失败补偿和多次加载尝试,降低冷启动首次播放失败概率。
|
||||||
|
* 初始化后可按广告位配置自动预热,避免高价值广告位首次点击才开始建链。
|
||||||
|
|
||||||
# [1.0.0]
|
# [1.0.0]
|
||||||
|
|
||||||
基础版本.
|
基础版本.
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ namespace Runtime.ADAggregator
|
|||||||
public class ADManager : MonoBehaviour
|
public class ADManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
private static ADManager _instance;
|
private static ADManager _instance;
|
||||||
private static bool mIsCreate = false;
|
private static bool mIsCreate = false;
|
||||||
private static bool mIsGMModel = false;
|
private static bool mIsGMModel = false;
|
||||||
|
|
||||||
public static ADManager Instance
|
public static ADManager Instance
|
||||||
{
|
{
|
||||||
@@ -22,7 +22,7 @@ namespace Runtime.ADAggregator
|
|||||||
Destroy(objs[i]);
|
Destroy(objs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
_instance = new GameObject().AddComponent<ADManager>();
|
_instance = new GameObject().AddComponent<ADManager>();
|
||||||
_instance.name = "[GameUpdater] <color=yellow>NoInit<color>";
|
_instance.name = "[GameUpdater] <color=yellow>NoInit<color>";
|
||||||
DontDestroyOnLoad(_instance);
|
DontDestroyOnLoad(_instance);
|
||||||
_instance.InitTimeSystem();
|
_instance.InitTimeSystem();
|
||||||
@@ -56,25 +56,31 @@ namespace Runtime.ADAggregator
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<bool> GLOBAL_ShowAwardVideoComplete;
|
public event Action<bool> GLOBAL_ShowAwardVideoComplete;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 全局任意视频广告玩家点击播放时
|
||||||
|
/// </summary>
|
||||||
|
public event Action<string , string> GLOBAL_ShowAwardVideoBefore;
|
||||||
|
|
||||||
public string UserId => _userId;
|
public string UserId => _userId;
|
||||||
|
|
||||||
#pragma warning disable CS0414
|
#pragma warning disable CS0414
|
||||||
private bool _isInit = false;
|
private bool _isInit = false;
|
||||||
#pragma warning restore CS0414
|
#pragma warning restore CS0414
|
||||||
|
|
||||||
public void Init(Action onCallback, string userId, ADConfig adConfig, IAdController controller,
|
public void Init(Action onCallback, string userId, ADConfig adConfig, IAdController controller,
|
||||||
params object[] args)
|
params object[] args)
|
||||||
{
|
{
|
||||||
_isInit = true;
|
_isInit = true;
|
||||||
_instance.name = "[GameUpdater] <color=green>Init<color>";
|
_instance.name = "[GameUpdater] <color=green>Init<color>";
|
||||||
AD_Dicts = new Dictionary<AD_Type, ADPlayer>();
|
AD_Dicts = new Dictionary<AD_Type, ADPlayer>();
|
||||||
_userId = userId;
|
_userId = userId;
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
onCallback?.Invoke();
|
onCallback?.Invoke();
|
||||||
#else
|
#else
|
||||||
controller.Init(adConfig , args);
|
controller.Init(adConfig , args);
|
||||||
_adController = controller;
|
_adController = controller;
|
||||||
_adConfig = adConfig;
|
_adConfig = adConfig;
|
||||||
|
PrewarmConfiguredPlayers();
|
||||||
onCallback?.Invoke();
|
onCallback?.Invoke();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -97,12 +103,12 @@ namespace Runtime.ADAggregator
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#pragma warning disable CS0162
|
#pragma warning disable CS0162
|
||||||
if (AD_Dicts.ContainsKey(adType) == false)
|
if (!TryGetOrCreatePlayer(adType, out var player))
|
||||||
{
|
{
|
||||||
AD_Dicts[adType] = PlayerCreate(adType);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return AD_Dicts[adType].IsReadly();
|
return player.IsReadly();
|
||||||
#pragma warning restore CS0162
|
#pragma warning restore CS0162
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,9 +123,9 @@ namespace Runtime.ADAggregator
|
|||||||
}
|
}
|
||||||
// Debug.LogError("准备加载广告" + adType);
|
// Debug.LogError("准备加载广告" + adType);
|
||||||
#pragma warning disable CS0162
|
#pragma warning disable CS0162
|
||||||
if (!IsRealy(adType))
|
if (!IsRealy(adType) && TryGetOrCreatePlayer(adType, out var player))
|
||||||
{
|
{
|
||||||
AD_Dicts[adType].LoadAD();
|
player.LoadAD();
|
||||||
}
|
}
|
||||||
#pragma warning restore CS0162
|
#pragma warning restore CS0162
|
||||||
}
|
}
|
||||||
@@ -140,11 +146,13 @@ namespace Runtime.ADAggregator
|
|||||||
/// <param name="callback"></param>
|
/// <param name="callback"></param>
|
||||||
public void AsyncPlayAD(AD_Type adType, string adScene, Action<bool> callback)
|
public void AsyncPlayAD(AD_Type adType, string adScene, Action<bool> callback)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (adType == AD_Type.AwardVideo)
|
if (adType == AD_Type.AwardVideo)
|
||||||
{
|
{
|
||||||
this.OnVideoComplete(true);
|
this.OnVideoComplete(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback?.Invoke(true);
|
callback?.Invoke(true);
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
@@ -153,17 +161,20 @@ namespace Runtime.ADAggregator
|
|||||||
callback?.Invoke(true);
|
callback?.Invoke(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_adController.EventLog("adScene", adScene);
|
_adController.EventLog("adScene", adScene);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_curAsyncPlayer?.Kill();
|
_curAsyncPlayer?.Kill();
|
||||||
if (AD_Dicts.ContainsKey(adType) == false)
|
if (!TryGetOrCreatePlayer(adType, out var player))
|
||||||
{
|
{
|
||||||
AD_Dicts[adType] = PlayerCreate(adType);
|
callback?.Invoke(false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var player = AD_Dicts[adType];
|
if (adType == AD_Type.AwardVideo)
|
||||||
_curAsyncPlayer = new AsyncAdPlayer(player, callback);
|
GLOBAL_ShowAwardVideoBefore?.Invoke(player.Key , NormalizeScenario(adScene));
|
||||||
|
_curAsyncPlayer = new AsyncAdPlayer(player, NormalizeScenario(adScene), callback);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -184,11 +195,74 @@ namespace Runtime.ADAggregator
|
|||||||
}
|
}
|
||||||
#pragma warning disable CS0162
|
#pragma warning disable CS0162
|
||||||
var adPlayer = _adController.CreateAdPlayer(type);
|
var adPlayer = _adController.CreateAdPlayer(type);
|
||||||
|
if (adPlayer == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
adPlayer.ADType = type;
|
adPlayer.ADType = type;
|
||||||
return adPlayer;
|
return adPlayer;
|
||||||
#pragma warning restore CS0162
|
#pragma warning restore CS0162
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void EnterAdScenario(AD_Type adType, string adScene)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
if (!_isInit || mIsGMModel)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#pragma warning disable CS0162
|
||||||
|
if (!TryGetOrCreatePlayer(adType, out var player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.EnterAdScenario(NormalizeScenario(adScene));
|
||||||
|
#pragma warning restore CS0162
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool TryGetOrCreatePlayer(AD_Type type, out ADPlayer player)
|
||||||
|
{
|
||||||
|
if (AD_Dicts.TryGetValue(type, out player) && player != null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
player = PlayerCreate(type);
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AD_Dicts[type] = player;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PrewarmConfiguredPlayers()
|
||||||
|
{
|
||||||
|
foreach (AD_Type adType in Enum.GetValues(typeof(AD_Type)))
|
||||||
|
{
|
||||||
|
if (!TryGetOrCreatePlayer(adType, out var player))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!player.AutoPreloadOnInit)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.LoadAD();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string NormalizeScenario(string scenario)
|
||||||
|
{
|
||||||
|
return string.IsNullOrWhiteSpace(scenario) ? "__default__" : scenario.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
public void CloseAd(AD_Type adType)
|
public void CloseAd(AD_Type adType)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
@@ -212,13 +286,13 @@ namespace Runtime.ADAggregator
|
|||||||
|
|
||||||
#region TimeSystem
|
#region TimeSystem
|
||||||
|
|
||||||
private List<Action> _updateList;
|
private List<Action> _updateList;
|
||||||
private const int DefaultLength = 1024;
|
private const int DefaultLength = 1024;
|
||||||
private List<AdTimeHandler> _timeHandlers;
|
private List<AdTimeHandler> _timeHandlers;
|
||||||
|
|
||||||
private void InitTimeSystem()
|
private void InitTimeSystem()
|
||||||
{
|
{
|
||||||
this._updateList = new List<Action>(DefaultLength);
|
this._updateList = new List<Action>(DefaultLength);
|
||||||
this._timeHandlers = new List<AdTimeHandler>();
|
this._timeHandlers = new List<AdTimeHandler>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,46 @@ namespace Runtime.ADAggregator
|
|||||||
protected int curState;
|
protected int curState;
|
||||||
|
|
||||||
public string Key;
|
public string Key;
|
||||||
|
public string AdScene;
|
||||||
protected ADListener adListener;
|
protected ADListener adListener;
|
||||||
public Action OnErrorAction;
|
public Action OnErrorAction;
|
||||||
|
public Action OnShowStartedAction;
|
||||||
|
|
||||||
public AD_Type ADType { get; internal set; }
|
public AD_Type ADType { get; internal set; }
|
||||||
|
|
||||||
public int State => curState;
|
public int State => curState;
|
||||||
|
|
||||||
|
public virtual int MaxLoadAttempts
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ADType == AD_Type.AwardVideo ? 2 : 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual float LoadRetryDelaySeconds
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ADType == AD_Type.AwardVideo ? 0.75f : 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual float ShowPendingTimeoutSeconds
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 5f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool AutoPreloadOnInit
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ADPlayer Init(string key)
|
public ADPlayer Init(string key)
|
||||||
{
|
{
|
||||||
this.Key = key;
|
this.Key = key;
|
||||||
@@ -44,6 +77,14 @@ namespace Runtime.ADAggregator
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void OnPlayRequestStarted()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void EnterAdScenario(string scenario)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 主动关闭广告
|
/// 主动关闭广告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -51,6 +92,11 @@ namespace Runtime.ADAggregator
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void NotifyShowStarted()
|
||||||
|
{
|
||||||
|
OnShowStartedAction?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
public void OnError(object code, string message)
|
public void OnError(object code, string message)
|
||||||
{
|
{
|
||||||
this.OnErrorAction?.Invoke();
|
this.OnErrorAction?.Invoke();
|
||||||
|
|||||||
@@ -5,23 +5,40 @@ namespace Runtime.ADAggregator
|
|||||||
{
|
{
|
||||||
public class AsyncAdPlayer
|
public class AsyncAdPlayer
|
||||||
{
|
{
|
||||||
private Action<bool> _callback;
|
private enum AsyncPlayPhase
|
||||||
private ADPlayer _adPlayer;
|
|
||||||
private bool firstLoad;
|
|
||||||
private bool isKill;
|
|
||||||
private bool isUpdate;
|
|
||||||
private AdTimeHandler overHandler;
|
|
||||||
|
|
||||||
private float _outTime;
|
|
||||||
|
|
||||||
public AsyncAdPlayer(ADPlayer player , Action<bool> callback)
|
|
||||||
{
|
{
|
||||||
|
Loading,
|
||||||
|
ShowPending,
|
||||||
|
Playing,
|
||||||
|
Closing,
|
||||||
|
Completed
|
||||||
|
}
|
||||||
|
|
||||||
this._outTime = 0;
|
private const float LoadTimeoutSeconds = 15f;
|
||||||
this._callback = callback;
|
private const float ShowAckTimeoutSeconds = 2f;
|
||||||
this.isKill = false;
|
|
||||||
this.firstLoad = true;
|
private Action<bool> _callback;
|
||||||
this._adPlayer = player;
|
private ADPlayer _adPlayer;
|
||||||
|
private bool isKill;
|
||||||
|
private bool isUpdate;
|
||||||
|
private int loadAttempts;
|
||||||
|
private float nextLoadRetryTime;
|
||||||
|
private AdTimeHandler overHandler;
|
||||||
|
private AdTimeHandler _showPendingHandler;
|
||||||
|
private string _adScene;
|
||||||
|
private AsyncPlayPhase _phase;
|
||||||
|
private float _loadElapsed;
|
||||||
|
|
||||||
|
public AsyncAdPlayer(ADPlayer player , string adScene, Action<bool> callback)
|
||||||
|
{
|
||||||
|
_adScene = adScene;
|
||||||
|
_loadElapsed = 0f;
|
||||||
|
_callback = callback;
|
||||||
|
isKill = false;
|
||||||
|
loadAttempts = 0;
|
||||||
|
nextLoadRetryTime = 0f;
|
||||||
|
_adPlayer = player;
|
||||||
|
_phase = AsyncPlayPhase.Loading;
|
||||||
if (_adPlayer == null)
|
if (_adPlayer == null)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
@@ -33,7 +50,10 @@ namespace Runtime.ADAggregator
|
|||||||
}
|
}
|
||||||
ADManager.Instance.OpenMask();
|
ADManager.Instance.OpenMask();
|
||||||
_adPlayer.OnErrorAction = OnError;
|
_adPlayer.OnErrorAction = OnError;
|
||||||
isUpdate = true;
|
_adPlayer.OnShowStartedAction = OnShowStarted;
|
||||||
|
_adPlayer.AdScene = _adScene;
|
||||||
|
_adPlayer.OnPlayRequestStarted();
|
||||||
|
isUpdate = true;
|
||||||
ADManager.Instance.AddUpdater(DoUpdate);
|
ADManager.Instance.AddUpdater(DoUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,71 +62,112 @@ namespace Runtime.ADAggregator
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
Debug.LogError("广告异常: " + this._adPlayer.Key);
|
Debug.LogError("广告异常: " + this._adPlayer.Key);
|
||||||
#endif
|
#endif
|
||||||
// return;
|
if (_phase == AsyncPlayPhase.Loading)
|
||||||
// if (isUpdate)
|
{
|
||||||
// {
|
return;
|
||||||
// isUpdate = false;
|
}
|
||||||
// ADManager.Instance.RemoveUpdater(DoUpdate);
|
|
||||||
// }
|
Fail(false);
|
||||||
// ADManager.Instance.CloseMask();
|
|
||||||
// _callback?.Invoke(false);
|
|
||||||
// Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoUpdate()
|
private void DoUpdate()
|
||||||
{
|
{
|
||||||
if (!isUpdate)
|
if (!isUpdate)
|
||||||
return;
|
|
||||||
_outTime += Time.deltaTime;
|
|
||||||
var callback = _callback;
|
|
||||||
if (this._outTime >= 15)
|
|
||||||
{
|
{
|
||||||
callback?.Invoke(false);
|
|
||||||
Kill();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (_phase)
|
||||||
|
{
|
||||||
|
case AsyncPlayPhase.Loading:
|
||||||
|
UpdateLoading();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateLoading()
|
||||||
|
{
|
||||||
|
_loadElapsed += Time.deltaTime;
|
||||||
|
if (_loadElapsed >= LoadTimeoutSeconds)
|
||||||
|
{
|
||||||
|
Fail(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_adPlayer.IsReadly())
|
if (_adPlayer.IsReadly())
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
BeginShow();
|
||||||
Debug.LogError("开始播放广告: " + this._adPlayer.Key);
|
|
||||||
#endif
|
|
||||||
_adPlayer.ShowAD(OnCloseAD, OnComplete);
|
|
||||||
if (_adPlayer.ADType != AD_Type.AwardVideo)
|
|
||||||
{
|
|
||||||
ADManager.Instance.CloseMask();
|
|
||||||
}
|
|
||||||
isUpdate = false;
|
|
||||||
ADManager.Instance.RemoveUpdater(DoUpdate);
|
|
||||||
}
|
}
|
||||||
else if(!_adPlayer.IsLoading())
|
else if (!_adPlayer.IsLoading())
|
||||||
{
|
{
|
||||||
if (firstLoad)
|
if (loadAttempts < _adPlayer.MaxLoadAttempts)
|
||||||
{
|
{
|
||||||
|
if (_loadElapsed < nextLoadRetryTime)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
Debug.LogError("开始加载广告: " + this._adPlayer.Key);
|
Debug.LogError("开始加载广告: " + this._adPlayer.Key);
|
||||||
#endif
|
#endif
|
||||||
this._outTime = 0;
|
|
||||||
_adPlayer.LoadAD();
|
_adPlayer.LoadAD();
|
||||||
firstLoad = false;
|
loadAttempts++;
|
||||||
|
nextLoadRetryTime = _loadElapsed + _adPlayer.LoadRetryDelaySeconds;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
callback?.Invoke(false);
|
Fail(false);
|
||||||
Kill();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void BeginShow()
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
Debug.LogError("开始播放广告: " + _adPlayer.Key);
|
||||||
|
#endif
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_phase = AsyncPlayPhase.ShowPending;
|
||||||
|
_showPendingHandler = ADManager.Instance.CreateTimer(
|
||||||
|
_adPlayer.ShowPendingTimeoutSeconds > 0 ? _adPlayer.ShowPendingTimeoutSeconds : ShowAckTimeoutSeconds,
|
||||||
|
() => Fail(false));
|
||||||
|
_adPlayer.ShowAD(OnCloseAD, OnComplete);
|
||||||
|
isUpdate = false;
|
||||||
|
ADManager.Instance.RemoveUpdater(DoUpdate);
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
Debug.LogError(exception);
|
||||||
|
_showPendingHandler?.Kill();
|
||||||
|
Fail(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnShowStarted()
|
||||||
|
{
|
||||||
|
if (isKill)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_phase = AsyncPlayPhase.Playing;
|
||||||
|
_showPendingHandler?.Kill();
|
||||||
|
ADManager.Instance.CloseMask();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnCloseAD()
|
private void OnCloseAD()
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
Debug.LogError("关闭广告: " + this._adPlayer.Key);
|
Debug.LogError("关闭广告: " + _adPlayer.Key);
|
||||||
#endif
|
#endif
|
||||||
|
_phase = AsyncPlayPhase.Closing;
|
||||||
|
_showPendingHandler?.Kill();
|
||||||
if (overHandler == null)
|
if (overHandler == null)
|
||||||
{
|
{
|
||||||
overHandler = ADManager.Instance.CreateTimer(1.5f, () =>
|
overHandler = ADManager.Instance.CreateTimer(1.5f, () =>
|
||||||
{
|
{
|
||||||
this._callback?.Invoke(false);
|
_callback?.Invoke(false);
|
||||||
Clear();
|
Clear();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -114,15 +175,26 @@ namespace Runtime.ADAggregator
|
|||||||
|
|
||||||
private void OnComplete(bool obj)
|
private void OnComplete(bool obj)
|
||||||
{
|
{
|
||||||
this.overHandler?.Kill();
|
_phase = AsyncPlayPhase.Completed;
|
||||||
this.overHandler = ADManager.Instance.CreateTimer(0.05f, () =>
|
_showPendingHandler?.Kill();
|
||||||
|
overHandler?.Kill();
|
||||||
|
overHandler = ADManager.Instance.CreateTimer(0.05f, () =>
|
||||||
{
|
{
|
||||||
ADManager.Instance.OnVideoComplete(obj);
|
if (_adPlayer != null && _adPlayer.ADType == AD_Type.AwardVideo)
|
||||||
|
{
|
||||||
|
ADManager.Instance.OnVideoComplete(obj);
|
||||||
|
}
|
||||||
_callback?.Invoke(obj);
|
_callback?.Invoke(obj);
|
||||||
Clear();
|
Clear();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Fail(bool result)
|
||||||
|
{
|
||||||
|
_callback?.Invoke(result);
|
||||||
|
Kill();
|
||||||
|
}
|
||||||
|
|
||||||
//销毁广告
|
//销毁广告
|
||||||
public void Kill()
|
public void Kill()
|
||||||
{
|
{
|
||||||
@@ -136,9 +208,16 @@ namespace Runtime.ADAggregator
|
|||||||
{
|
{
|
||||||
ADManager.Instance.CloseMask();
|
ADManager.Instance.CloseMask();
|
||||||
isKill = true;
|
isKill = true;
|
||||||
|
isUpdate = false;
|
||||||
|
if (_adPlayer != null)
|
||||||
|
{
|
||||||
|
_adPlayer.OnErrorAction = null;
|
||||||
|
_adPlayer.OnShowStartedAction = null;
|
||||||
|
}
|
||||||
_callback = null;
|
_callback = null;
|
||||||
_adPlayer = null;
|
_adPlayer = null;
|
||||||
this.overHandler = null;
|
overHandler = null;
|
||||||
|
_showPendingHandler = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "com.foldcc.cc-framework.commercialization",
|
"name": "com.foldcc.cc-framework.commercialization",
|
||||||
"displayName": "CC-Framework.commercialization",
|
"displayName": "CC-Framework.commercialization",
|
||||||
"description": "商业化sdk通用组件,包含广告、内购、用户统计、归因统计等",
|
"description": "商业化sdk通用组件,包含广告、内购、用户统计、归因统计等",
|
||||||
"version": "1.0.7",
|
"version": "1.0.14",
|
||||||
"unity": "2021.1",
|
"unity": "2021.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
Reference in New Issue
Block a user