feat: add editor ad placement diagnostics

This commit is contained in:
2026-06-17 18:21:24 +08:00
parent 3fcd4a5af8
commit a90e5c8d21
4 changed files with 32 additions and 4 deletions

View File

@@ -1,3 +1,9 @@
# [1.0.16]
### 新增
* `ADManager` 在 Unity Editor 模拟广告播放和进入广告场景时,会调用可选的 `IAdEditorDiagnostics` 诊断接口,便于渠道实现输出当前场景实际使用的广告位。
# [1.0.15] # [1.0.15]
### 调整 ### 调整

View File

@@ -51,6 +51,8 @@ namespace Runtime.ADAggregator
private string _userId; private string _userId;
private object[] _initArgs;
/// <summary> /// <summary>
/// 全局任意视频广告播放结束后事件, bool 表示是否完成奖励 /// 全局任意视频广告播放结束后事件, bool 表示是否完成奖励
/// </summary> /// </summary>
@@ -74,12 +76,13 @@ namespace Runtime.ADAggregator
_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;
_adController = controller;
_adConfig = adConfig;
_initArgs = args;
#if UNITY_EDITOR #if UNITY_EDITOR
onCallback?.Invoke(); onCallback?.Invoke();
#else #else
controller.Init(adConfig , args); controller.Init(adConfig , args);
_adController = controller;
_adConfig = adConfig;
PrewarmConfiguredPlayers(); PrewarmConfiguredPlayers();
onCallback?.Invoke(); onCallback?.Invoke();
#endif #endif
@@ -148,6 +151,7 @@ namespace Runtime.ADAggregator
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
LogEditorAdPlacement(adType, adScene, "play");
if (adType == AD_Type.AwardVideo) if (adType == AD_Type.AwardVideo)
{ {
this.OnVideoComplete(true); this.OnVideoComplete(true);
@@ -207,6 +211,7 @@ namespace Runtime.ADAggregator
public void EnterAdScenario(AD_Type adType, string adScene) public void EnterAdScenario(AD_Type adType, string adScene)
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
LogEditorAdPlacement(adType, adScene, "enter_scene");
return; return;
#endif #endif
if (!_isInit || mIsGMModel) if (!_isInit || mIsGMModel)
@@ -263,6 +268,18 @@ namespace Runtime.ADAggregator
return string.IsNullOrWhiteSpace(scenario) ? "__default__" : scenario.Trim(); return string.IsNullOrWhiteSpace(scenario) ? "__default__" : scenario.Trim();
} }
private void LogEditorAdPlacement(AD_Type adType, string adScene, string action)
{
var normalizedScene = NormalizeScenario(adScene);
if (_adController is IAdEditorDiagnostics diagnostics)
{
diagnostics.LogEditorAdPlacement(_adConfig, adType, normalizedScene, action, _initArgs);
return;
}
Debug.Log($"[ADManager] Editor ad {action}. type={adType}, scene={normalizedScene}");
}
public void CloseAd(AD_Type adType) public void CloseAd(AD_Type adType)
{ {
#if UNITY_EDITOR #if UNITY_EDITOR

View File

@@ -7,4 +7,9 @@
void EventLog(string eventTable, string eventValue, string eventMessage = null); void EventLog(string eventTable, string eventValue, string eventMessage = null);
void SetMask(bool isOpen); void SetMask(bool isOpen);
} }
public interface IAdEditorDiagnostics
{
void LogEditorAdPlacement(ADConfig adConfig, AD_Type adType, string adScene, string action, object[] args);
}
} }

View File

@@ -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.15", "version": "1.0.16",
"unity": "2022.3", "unity": "2022.3",
"license": "MIT", "license": "MIT",
"repository": { "repository": {