You've already forked CC-Framework.Commercialization
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b53846c98f | |||
| 89f5f66322 | |||
| acff3d126b |
@@ -51,6 +51,11 @@ namespace Runtime.ADAggregator
|
|||||||
|
|
||||||
private string _userId;
|
private string _userId;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 全局任意视频广告播放结束后事件, bool 表示是否完成奖励
|
||||||
|
/// </summary>
|
||||||
|
public event Action<bool> GLOBAL_ShowAwardVideoComplete;
|
||||||
|
|
||||||
public string UserId => _userId;
|
public string UserId => _userId;
|
||||||
|
|
||||||
#pragma warning disable CS0414
|
#pragma warning disable CS0414
|
||||||
@@ -136,6 +141,10 @@ namespace Runtime.ADAggregator
|
|||||||
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)
|
||||||
|
{
|
||||||
|
this.OnVideoComplete(true);
|
||||||
|
}
|
||||||
callback?.Invoke(true);
|
callback?.Invoke(true);
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
@@ -154,7 +163,7 @@ namespace Runtime.ADAggregator
|
|||||||
}
|
}
|
||||||
|
|
||||||
var player = AD_Dicts[adType];
|
var player = AD_Dicts[adType];
|
||||||
_curAsyncPlayer = new AsyncAdPlayer(player, callback);
|
_curAsyncPlayer = new AsyncAdPlayer(player,adScene , callback);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -174,7 +183,9 @@ namespace Runtime.ADAggregator
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
#pragma warning disable CS0162
|
#pragma warning disable CS0162
|
||||||
return _adController.CreateAdPlayer(type);
|
var adPlayer = _adController.CreateAdPlayer(type);
|
||||||
|
adPlayer.ADType = type;
|
||||||
|
return adPlayer;
|
||||||
#pragma warning restore CS0162
|
#pragma warning restore CS0162
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,5 +307,10 @@ namespace Runtime.ADAggregator
|
|||||||
{
|
{
|
||||||
_adController.SetMask(true);
|
_adController.SetMask(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void OnVideoComplete(bool isComplete)
|
||||||
|
{
|
||||||
|
GLOBAL_ShowAwardVideoComplete?.Invoke(isComplete);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,9 +10,12 @@ 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 AD_Type ADType { get; internal set; }
|
||||||
|
|
||||||
public int State => curState;
|
public int State => curState;
|
||||||
|
|
||||||
public ADPlayer Init(string key)
|
public ADPlayer Init(string key)
|
||||||
|
|||||||
@@ -5,21 +5,23 @@ namespace Runtime.ADAggregator
|
|||||||
{
|
{
|
||||||
public class AsyncAdPlayer
|
public class AsyncAdPlayer
|
||||||
{
|
{
|
||||||
private Action<bool> _callback;
|
private Action<bool> _callback;
|
||||||
private ADPlayer _adPlayer;
|
private ADPlayer _adPlayer;
|
||||||
private bool firstLoad;
|
private bool firstLoad;
|
||||||
private bool isKill;
|
private bool isKill;
|
||||||
private bool isUpdate;
|
private bool isUpdate;
|
||||||
private AdTimeHandler overHandler;
|
private AdTimeHandler overHandler;
|
||||||
|
private string _Ad_scene;
|
||||||
|
|
||||||
private float _outTime;
|
private float _outTime;
|
||||||
|
|
||||||
public AsyncAdPlayer(ADPlayer player , Action<bool> callback)
|
public AsyncAdPlayer(ADPlayer player , string adScene, Action<bool> callback)
|
||||||
{
|
{
|
||||||
|
|
||||||
this._outTime = 0;
|
this._Ad_scene = adScene;
|
||||||
|
this._outTime = 0;
|
||||||
this._callback = callback;
|
this._callback = callback;
|
||||||
this.isKill = false;
|
this.isKill = false;
|
||||||
this.firstLoad = true;
|
this.firstLoad = true;
|
||||||
this._adPlayer = player;
|
this._adPlayer = player;
|
||||||
if (_adPlayer == null)
|
if (_adPlayer == null)
|
||||||
@@ -33,7 +35,8 @@ namespace Runtime.ADAggregator
|
|||||||
}
|
}
|
||||||
ADManager.Instance.OpenMask();
|
ADManager.Instance.OpenMask();
|
||||||
_adPlayer.OnErrorAction = OnError;
|
_adPlayer.OnErrorAction = OnError;
|
||||||
isUpdate = true;
|
_adPlayer.AdScene = this._Ad_scene;
|
||||||
|
isUpdate = true;
|
||||||
ADManager.Instance.AddUpdater(DoUpdate);
|
ADManager.Instance.AddUpdater(DoUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,10 +61,12 @@ namespace Runtime.ADAggregator
|
|||||||
if (!isUpdate)
|
if (!isUpdate)
|
||||||
return;
|
return;
|
||||||
_outTime += Time.deltaTime;
|
_outTime += Time.deltaTime;
|
||||||
|
var callback = _callback;
|
||||||
if (this._outTime >= 15)
|
if (this._outTime >= 15)
|
||||||
{
|
{
|
||||||
_callback?.Invoke(false);
|
callback?.Invoke(false);
|
||||||
Kill();
|
Kill();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (_adPlayer.IsReadly())
|
if (_adPlayer.IsReadly())
|
||||||
{
|
{
|
||||||
@@ -69,7 +74,10 @@ namespace Runtime.ADAggregator
|
|||||||
Debug.LogError("开始播放广告: " + this._adPlayer.Key);
|
Debug.LogError("开始播放广告: " + this._adPlayer.Key);
|
||||||
#endif
|
#endif
|
||||||
_adPlayer.ShowAD(OnCloseAD, OnComplete);
|
_adPlayer.ShowAD(OnCloseAD, OnComplete);
|
||||||
ADManager.Instance.CloseMask();
|
if (_adPlayer.ADType != AD_Type.AwardVideo)
|
||||||
|
{
|
||||||
|
ADManager.Instance.CloseMask();
|
||||||
|
}
|
||||||
isUpdate = false;
|
isUpdate = false;
|
||||||
ADManager.Instance.RemoveUpdater(DoUpdate);
|
ADManager.Instance.RemoveUpdater(DoUpdate);
|
||||||
}
|
}
|
||||||
@@ -86,7 +94,7 @@ namespace Runtime.ADAggregator
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_callback?.Invoke(false);
|
callback?.Invoke(false);
|
||||||
Kill();
|
Kill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,6 +120,7 @@ namespace Runtime.ADAggregator
|
|||||||
this.overHandler?.Kill();
|
this.overHandler?.Kill();
|
||||||
this.overHandler = ADManager.Instance.CreateTimer(0.05f, () =>
|
this.overHandler = ADManager.Instance.CreateTimer(0.05f, () =>
|
||||||
{
|
{
|
||||||
|
ADManager.Instance.OnVideoComplete(obj);
|
||||||
_callback?.Invoke(obj);
|
_callback?.Invoke(obj);
|
||||||
Clear();
|
Clear();
|
||||||
});
|
});
|
||||||
@@ -122,13 +131,13 @@ namespace Runtime.ADAggregator
|
|||||||
{
|
{
|
||||||
if (isKill)
|
if (isKill)
|
||||||
return;
|
return;
|
||||||
ADManager.Instance.CloseMask();
|
|
||||||
ADManager.Instance.RemoveUpdater(DoUpdate);
|
ADManager.Instance.RemoveUpdater(DoUpdate);
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Clear()
|
private void Clear()
|
||||||
{
|
{
|
||||||
|
ADManager.Instance.CloseMask();
|
||||||
isKill = true;
|
isKill = true;
|
||||||
_callback = null;
|
_callback = null;
|
||||||
_adPlayer = null;
|
_adPlayer = null;
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 094f67b7dbe0a8d4bb32d358c57004c6
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -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.5",
|
"version": "1.0.9",
|
||||||
"unity": "2021.1",
|
"unity": "2021.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
Reference in New Issue
Block a user