Files
Commercialization.tapadn/Assets/Tapadn_Adapter/Runtime/Scripts/TapadnCommercialization.cs
2026-06-17 15:40:25 +08:00

63 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using Runtime.ADAggregator;
public static class TapadnCommercialization
{
public static TapadnAdController CreateController()
{
return new TapadnAdController();
}
public static void InitADManager(Action onCallback, string userId, ADConfig adConfig, params object[] args)
{
ADManager.Instance.Init(onCallback, userId, adConfig, CreateController(), args);
}
public static ADConfig CreateConfig(
string mediaId,
string mediaKey,
string mediaName,
string rewardSlotId,
string interstitialSlotId = null,
string splashSlotId = null)
{
var config = UnityEngine.ScriptableObject.CreateInstance<ADConfig>();
config.ConfigName = "TapADN";
config.Id = mediaId;
config.Key = mediaKey;
config.Key2 = mediaName;
config.BaseAwardAdKeyValue = new AdKeyValue { key = "reward", value = rewardSlotId };
config.BaseInteractionAdKeyValue = new AdKeyValue { key = "interaction", value = interstitialSlotId };
config.BaseSplashAdKeyValue = new AdKeyValue { key = "splash", value = splashSlotId };
return config;
}
public static void SetRewardedSceneSlots(ADConfig config, IDictionary<string, string> sceneSlotIds)
{
if (config == null || sceneSlotIds == null || sceneSlotIds.Count == 0)
{
return;
}
if (config.CommonKeyValues == null)
{
config.CommonKeyValues = new List<AdKeyValue>();
}
foreach (var entry in sceneSlotIds)
{
if (string.IsNullOrWhiteSpace(entry.Key) || string.IsNullOrWhiteSpace(entry.Value))
{
continue;
}
config.CommonKeyValues.Add(new AdKeyValue
{
key = TapadnControllerOptions.RewardedSceneSlotPrefix + entry.Key.Trim(),
value = entry.Value.Trim()
});
}
}
}