This commit is contained in:
2023-01-29 12:44:57 +08:00
commit 474dbdbd34
328 changed files with 21484 additions and 0 deletions

8
AnyThinkAds.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 687c8129e7770fe47aa2bdceaab14b6b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
AnyThinkAds/Api.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 91a7a1e184c2641f79c95f363b8872d2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,194 @@
using System;
using System.Collections;
using AnyThinkAds.Api;
namespace AnyThinkAds.Api
{
public class ATAdEventArgs
{
public String placementId { get; }
public ATCallbackInfo callbackInfo { get; }
public ATAdEventArgs(String id)
{
placementId = id;
callbackInfo = new ATCallbackInfo("");
}
public ATAdEventArgs(String id, String callbackJson)
{
placementId = id;
callbackInfo = new ATCallbackInfo(callbackJson);
}
}
public class ATAdErrorEventArgs : ATAdEventArgs
{
public String errorMessage { get; }
public String errorCode { get; }
public ATAdErrorEventArgs(String placementId, String message, String code)
: base(placementId)
{
errorMessage = message;
errorCode = code;
}
public ATAdErrorEventArgs(String placementId, String callbackJson, String message, String code)
: base(placementId, callbackJson)
{
errorMessage = message;
errorCode = code;
}
}
public class ATAdProgressEventArgs : ATAdEventArgs
{
public int adProgress { get; }
public ATAdProgressEventArgs(String placementId, String callbackJson, int progress)
: base(placementId, callbackJson)
{
adProgress = progress;
}
}
public class ATAdRewardEventArgs : ATAdEventArgs
{
public bool isRewarded { get; }
public ATAdRewardEventArgs(String placementId, String callbackJson, bool doReward)
: base(placementId, callbackJson)
{
isRewarded = doReward;
}
}
public interface IHCommonEvents
{
// triggers when the ad has been succesfully loaded
event EventHandler<ATAdEventArgs> onAdLoadEvent;
// triggers when the ad has failed to load
event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
// triggers when a the ad has started to load
event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
// triggers when a the ad has finished to load
event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
// triggers when a the ad has started to load
event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
// triggers when a the ad has started to load
event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
// triggers when a the ad has started to load
event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
// triggers when a the ad has started to load
event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
}
public interface IATBannerEvents: IHCommonEvents
{
// triggers when a banner ad generates an impression
event EventHandler<ATAdEventArgs> onAdImpressEvent;
// triggers when the user clicks a banner ad
event EventHandler<ATAdEventArgs> onAdClickEvent;
// triggers when the ad refreshes
event EventHandler<ATAdEventArgs> onAdAutoRefreshEvent;
// triggers when the ad fails to auto refresh
event EventHandler<ATAdErrorEventArgs> onAdAutoRefreshFailureEvent;
// triggers when the banner ad is closed
event EventHandler<ATAdEventArgs> onAdCloseEvent;
// triggers when the users closes the ad via the button
event EventHandler<ATAdEventArgs> onAdCloseButtonTappedEvent;
}
public interface IATInterstitialAdEvents : IHCommonEvents
{
// called when the ad is shown
event EventHandler<ATAdEventArgs> onAdShowEvent;
// called if the ad has failed to be shown
event EventHandler<ATAdErrorEventArgs> onAdShowFailureEvent;
// called when the ad is closed
event EventHandler<ATAdEventArgs> onAdCloseEvent;
// called when an user has clicked an ad
event EventHandler<ATAdEventArgs> onAdClickEvent;
// called when a video ad has started playing
event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
// called if an ad video has failed to be displayed
event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
// called when ad video has finished
event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
}
public interface IATNativeAdEvents : IHCommonEvents
{
// triggers when the ad generates an impression
event EventHandler<ATAdEventArgs> onAdImpressEvent;
// triggers when the user clicks the ad
event EventHandler<ATAdEventArgs> onAdClickEvent;
// triggers when the ad video starts
event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
// triggers when the ad video ends
event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
// triggers if the ad progresses
event EventHandler<ATAdProgressEventArgs> onAdVideoProgressEvent;
// triggers when the ad is closed
event EventHandler<ATAdEventArgs> onAdCloseEvent;
}
public interface IATRewardedVideoEvents : IHCommonEvents
{
// triggers on video start
event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
// triggers on video end
event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
// triggers if the video fails to play
event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
// triggers when the user has closed the ad
event EventHandler<ATAdRewardEventArgs> onAdVideoCloseEvent;
// triggers when the user has clicked the ad
event EventHandler<ATAdEventArgs> onAdClickEvent;
// triggers when the user has finsihed watching the ad and should be rewarded
event EventHandler<ATAdEventArgs> onRewardEvent;
event EventHandler<ATAdEventArgs> onPlayAgainStart;
event EventHandler<ATAdEventArgs> onPlayAgainEnd;
event EventHandler<ATAdErrorEventArgs> onPlayAgainFailure;
event EventHandler<ATAdEventArgs> onPlayAgainClick;
event EventHandler<ATAdEventArgs> onPlayAgainReward;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 219a4269ecae84c4e9d5b84de8b992de
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,130 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
using System;
using AnyThinkAds.Common;
using AnyThinkAds.ThirdParty.LitJson;
namespace AnyThinkAds.Api
{
public class ATBannerAdLoadingExtra
{
public static readonly string kATBannerAdLoadingExtraBannerAdSize = "banner_ad_size";
public static readonly string kATBannerAdLoadingExtraBannerAdSizeStruct = "banner_ad_size_struct";
public static readonly string kATBannerAdSizeUsesPixelFlagKey = "uses_pixel";
public static readonly string kATBannerAdShowingPisitionTop = "top";
public static readonly string kATBannerAdShowingPisitionBottom = "bottom";
//Deprecated in v5.7.3
public static readonly string kATBannerAdLoadingExtraInlineAdaptiveWidth = "inline_adaptive_width";
public static readonly string kATBannerAdLoadingExtraInlineAdaptiveOrientation = "inline_adaptive_orientation";
public static readonly int kATBannerAdLoadingExtraInlineAdaptiveOrientationCurrent = 0;
public static readonly int kATBannerAdLoadingExtraInlineAdaptiveOrientationPortrait = 1;
public static readonly int kATBannerAdLoadingExtraInlineAdaptiveOrientationLandscape = 2;
//Deprecated in v5.7.3
public static readonly string kATBannerAdLoadingExtraAdaptiveWidth = "adaptive_width";
public static readonly string kATBannerAdLoadingExtraAdaptiveOrientation = "adaptive_orientation";
public static readonly int kATBannerAdLoadingExtraAdaptiveOrientationCurrent = 0;
public static readonly int kATBannerAdLoadingExtraAdaptiveOrientationPortrait = 1;
public static readonly int kATBannerAdLoadingExtraAdaptiveOrientationLandscape = 2;
}
public class ATBannerAd
{
private static readonly ATBannerAd instance = new ATBannerAd();
public IATBannerAdClient client;
private ATBannerAd()
{
client = GetATBannerAdClient();
}
public static ATBannerAd Instance
{
get
{
return instance;
}
}
/**
API
*/
public void loadBannerAd(string placementId, Dictionary<string,object> pairs)
{
if (pairs != null && pairs.ContainsKey(ATBannerAdLoadingExtra.kATBannerAdLoadingExtraBannerAdSize))
{
client.loadBannerAd(placementId, JsonMapper.ToJson(pairs));
}
else if (pairs != null && pairs.ContainsKey(ATBannerAdLoadingExtra.kATBannerAdLoadingExtraBannerAdSizeStruct))
{
ATSize size = (ATSize)(pairs[ATBannerAdLoadingExtra.kATBannerAdLoadingExtraBannerAdSizeStruct]);
pairs.Add(ATBannerAdLoadingExtra.kATBannerAdLoadingExtraBannerAdSize, size.width + "x" + size.height);
pairs.Add(ATBannerAdLoadingExtra.kATBannerAdSizeUsesPixelFlagKey, size.usesPixel);
//Dictionary<string, object> newPaires = new Dictionary<string, object> { { ATBannerAdLoadingExtra.kATBannerAdLoadingExtraBannerAdSize, size.width + "x" + size.height }, { ATBannerAdLoadingExtra.kATBannerAdSizeUsesPixelFlagKey, size.usesPixel } };
client.loadBannerAd(placementId, JsonMapper.ToJson(pairs));
}
else
{
client.loadBannerAd(placementId, JsonMapper.ToJson(pairs));
}
}
public string checkAdStatus(string placementId)
{
return client.checkAdStatus(placementId);
}
public string getValidAdCaches(string placementId)
{
return client.getValidAdCaches(placementId);
}
public void showBannerAd(string placementId, ATRect rect)
{
client.showBannerAd(placementId, rect, "");
}
public void showBannerAd(string placementId, ATRect rect, Dictionary<string,string> pairs)
{
client.showBannerAd(placementId, rect, JsonMapper.ToJson(pairs));
}
public void showBannerAd(string placementId, string position)
{
client.showBannerAd(placementId, position, "");
}
public void showBannerAd(string placementId, string position, Dictionary<string,string> pairs)
{
client.showBannerAd(placementId, position, JsonMapper.ToJson(pairs));
}
public void showBannerAd(string placementId)
{
client.showBannerAd(placementId);
}
public void hideBannerAd(string placementId)
{
client.hideBannerAd(placementId);
}
public void cleanBannerAd(string placementId)
{
client.cleanBannerAd(placementId);
}
public IATBannerAdClient GetATBannerAdClient()
{
return AnyThinkAds.ATAdsClientFactory.BuildBannerAdClient();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c8137f9ecda484f4f82280927f6cc6d3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,57 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AnyThinkAds.Api
{
public interface ATBannerAdListener
{
/***
* 广告请求成功注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdLoad(string placementId);
/***
* 广告请求失败注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdLoadFail(string placementId, string code, string message);
/***
* 广告展示注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdImpress(string placementId, ATCallbackInfo callbackInfo);
/**
* 广告点击注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdClick(string placementId, ATCallbackInfo callbackInfo);
/**
* 广告自动刷新注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdAutoRefresh(string placementId, ATCallbackInfo callbackInfo);
/**
*广告自动刷新失败注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdAutoRefreshFail(string placementId, string code, string message);
/**
*广告关闭某些厂商不支持注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdClose(string placementId);
/**
*广告关闭某些厂商不支持注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdCloseButtonTapped(string placementId, ATCallbackInfo callbackInfo);
void startLoadingADSource(string placementId, ATCallbackInfo callbackInfo);
void finishLoadingADSource(string placementId, ATCallbackInfo callbackInfo);
void failToLoadADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message);
void startBiddingADSource(string placementId, ATCallbackInfo callbackInfo);
void finishBiddingADSource(string placementId, ATCallbackInfo callbackInfo);
void failBiddingADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 82a2859cc834c4a2f92c6497ca4ffa5f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,146 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.ThirdParty.LitJson;
namespace AnyThinkAds.Api
{
public class ATCallbackInfo
{
public readonly int network_firm_id;
public readonly string adsource_id;
public readonly int adsource_index;
public readonly double adsource_price;
public readonly int adsource_isheaderbidding;
public readonly string id;
public readonly double publisher_revenue;
public readonly string currency;
public readonly string country;
public readonly string adunit_id;
public readonly string adunit_format;
public readonly string precision;
public readonly string network_type;
public readonly string network_placement_id;
public readonly int ecpm_level;
public readonly int segment_id;
public readonly string scenario_id;
public readonly string scenario_reward_name;
public readonly int scenario_reward_number;
public readonly string sub_channel;
public readonly string channel;
public readonly Dictionary<string, object> custom_rule;
public readonly string reward_custom_data;
private string callbackJson;
public ATCallbackInfo(string callbackJson)
{
try
{
this.callbackJson = callbackJson;
JsonData jsonData = JsonMapper.ToObject(callbackJson);
network_firm_id = int.Parse(jsonData.ContainsKey("network_firm_id") ? jsonData["network_firm_id"].ToString() : "0");
adsource_id = jsonData.ContainsKey("adsource_id") ? (string)jsonData["adsource_id"] : "";
adsource_index = int.Parse(jsonData.ContainsKey("adsource_index") ? jsonData["adsource_index"].ToString() : "-1");
adsource_price = double.Parse(jsonData.ContainsKey("adsource_price") ? jsonData["adsource_price"].ToString() : "0");
adsource_isheaderbidding = 0;
if (jsonData.ContainsKey("adsource_isheaderbidding")) {
adsource_isheaderbidding = int.Parse(jsonData.ContainsKey("adsource_isheaderbidding") ? jsonData["adsource_isheaderbidding"].ToString() : "0");
}
id = jsonData.ContainsKey("id") ? (string)jsonData["id"] : "";
publisher_revenue = double.Parse(jsonData.ContainsKey("publisher_revenue") ? jsonData["publisher_revenue"].ToString() : "0");
currency = jsonData.ContainsKey("currency") ? (string)jsonData["currency"] : "";
country = jsonData.ContainsKey("country") ? (string)jsonData["country"] : "";
adunit_format = jsonData.ContainsKey("adunit_format") ? (string)jsonData["adunit_format"] : "";
adunit_id = jsonData.ContainsKey("adunit_id") ? (string)jsonData["adunit_id"] : "";
precision = jsonData.ContainsKey("precision") ? (string)jsonData["precision"] : "";
network_type = jsonData.ContainsKey("network_type") ? (string)jsonData["network_type"] : "";
network_placement_id = jsonData.ContainsKey("network_placement_id") ? (string)jsonData["network_placement_id"] : "";
ecpm_level = int.Parse(jsonData.ContainsKey("ecpm_level") ? jsonData["ecpm_level"].ToString() : "0");
segment_id = int.Parse(jsonData.ContainsKey("segment_id") ? jsonData["segment_id"].ToString() : "0");
scenario_id = jsonData.ContainsKey("scenario_id") ? (string)jsonData["scenario_id"] : "";// RewardVideo & Interstitial
scenario_reward_name = jsonData.ContainsKey("scenario_reward_name") ? (string)jsonData["scenario_reward_name"] : "";
scenario_reward_number = int.Parse(jsonData.ContainsKey("scenario_reward_number") ? jsonData["scenario_reward_number"].ToString() : "0");
channel = jsonData.ContainsKey("channel") ? (string)jsonData["channel"] : "";
sub_channel = jsonData.ContainsKey("sub_channel") ? (string)jsonData["sub_channel"] : "";
custom_rule = jsonData.ContainsKey("custom_rule") ? JsonMapper.ToObject<Dictionary<string, object>>(jsonData["custom_rule"].ToJson()) : null;
reward_custom_data = jsonData.ContainsKey("reward_custom_data") ? (string)jsonData["reward_custom_data"] : "";
}
catch (System.Exception e) {
System.Console.WriteLine("Exception caught: {0}", e);
}
}
public string getOriginJSONString()
{
return callbackJson;
}
public Dictionary<string, object> toAdsourceDictionary()
{
Dictionary<string, object> dataDictionary = new Dictionary<string, object>();
dataDictionary.Add("adsource_id", adsource_id);
dataDictionary.Add("adsource_price", adsource_price);
dataDictionary.Add("adunit_id", adunit_id);
dataDictionary.Add("currency", currency);
dataDictionary.Add("network_firm_id",network_firm_id);
dataDictionary.Add("network_placement_id",network_placement_id);
return dataDictionary;
}
public Dictionary<string, object> toDictionary()
{
Dictionary<string, object> dataDictionary = new Dictionary<string, object>();
dataDictionary.Add("network_firm_id",network_firm_id);
dataDictionary.Add("adsource_id", adsource_id);
dataDictionary.Add("adsource_index", adsource_index);
dataDictionary.Add("adsource_price", adsource_price);
dataDictionary.Add("adsource_isheaderbidding", adsource_isheaderbidding);
dataDictionary.Add("id", id);
dataDictionary.Add("publisher_revenue", publisher_revenue);
dataDictionary.Add("currency", currency);
dataDictionary.Add("country", country);
dataDictionary.Add("adunit_id", adunit_id);
dataDictionary.Add("adunit_format", adunit_format);
dataDictionary.Add("precision", precision);
dataDictionary.Add("network_type", network_type);
dataDictionary.Add("network_placement_id",network_placement_id);
dataDictionary.Add("ecpm_level", ecpm_level);
dataDictionary.Add("segment_id", segment_id);
dataDictionary.Add("scenario_id", scenario_id);
dataDictionary.Add("scenario_reward_name", scenario_reward_name);
dataDictionary.Add("scenario_reward_number", scenario_reward_number);
dataDictionary.Add("sub_channel", sub_channel);
dataDictionary.Add("channel", channel);
dataDictionary.Add("custom_rule", custom_rule);
dataDictionary.Add("reward_custom_data", reward_custom_data);
return dataDictionary;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d71af2c579e014d268a0dfa493b7b42a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AnyThinkAds.Api
{
public class ATConst {
public const string ADAPTIVE_HEIGHT = "AdaptiveHeight";//value is string
public const string ADAPTIVE_HEIGHT_YES = "1";
public const string POSITION = "Position";//value is string
public const string POSITION_TOP = "Top";
public const string POSITION_BOTTOM = "Bottom";
public const string SCENARIO = "Scenario";//value is string
public const string USERID_KEY = "UserId";//value is string
public const string USER_EXTRA_DATA = "UserExtraData"; //value is string
public const string USE_REWARDED_VIDEO_AS_INTERSTITIAL = "UseRewardedVideoAsInterstitial";//value is string
public const string USE_REWARDED_VIDEO_AS_INTERSTITIAL_YES = "1";
public const string USE_REWARDED_VIDEO_AS_INTERSTITIAL_NO = "0";
public const string WIDTH = "Width";//value is string
public const string HEIGHT = "Height";//value is string
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 96cb1512452b44892ab41a110737bc6f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@

namespace AnyThinkAds.Api
{
public interface ATDownloadAdListener
{
void onDownloadStart(string placementId, ATCallbackInfo callbackInfo, long totalBytes, long currBytes, string fileName, string appName);
void onDownloadUpdate(string placementId, ATCallbackInfo callbackInfo, long totalBytes, long currBytes, string fileName, string appName);
void onDownloadPause(string placementId, ATCallbackInfo callbackInfo, long totalBytes, long currBytes, string fileName, string appName);
void onDownloadFinish(string placementId, ATCallbackInfo callbackInfo, long totalBytes, string fileName, string appName);
void onDownloadFail(string placementId, ATCallbackInfo callbackInfo, long totalBytes, long currBytes, string fileName, string appName);
void onInstalled(string placementId, ATCallbackInfo callbackInfo, string fileName, string appName);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c23fcd22e05664d73ba39e69a58fdfdb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@

using AnyThinkAds.Common;
namespace AnyThinkAds.Api
{
public class ATDownloadManager
{
private static readonly ATDownloadManager instance = new ATDownloadManager();
private IATDownloadClient client;
private ATDownloadManager()
{
client = GetATDownloadClient();
}
public static ATDownloadManager Instance
{
get
{
return instance;
}
}
public void setListener(ATDownloadAdListener listener)
{
client.setListener(listener);
}
public IATDownloadClient GetATDownloadClient()
{
return AnyThinkAds.ATAdsClientFactory.BuildDownloadClient();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 88edb880a748a4df7be4481415e44907
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,89 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
using System;
using AnyThinkAds.Common;
using AnyThinkAds.ThirdParty.LitJson;
namespace AnyThinkAds.Api
{
public class ATInterstitialAdLoadingExtra
{
public static readonly string kATInterstitialAdLoadingExtraInterstitialAdSize = "interstitial_ad_size";
public static readonly string kATInterstitialAdLoadingExtraInterstitialAdSizeStruct = "interstitial_ad_size_struct";
public static readonly string kATInterstitialAdSizeUsesPixelFlagKey = "uses_pixel";
}
public class ATInterstitialAd
{
private static readonly ATInterstitialAd instance = new ATInterstitialAd();
public IATInterstitialAdClient client;
private ATInterstitialAd()
{
client = GetATInterstitialAdClient();
}
public static ATInterstitialAd Instance
{
get
{
return instance;
}
}
public void loadInterstitialAd(string placementId, Dictionary<string,object> pairs)
{
if (pairs != null && pairs.ContainsKey(ATInterstitialAdLoadingExtra.kATInterstitialAdLoadingExtraInterstitialAdSizeStruct))
{
ATSize size = (ATSize)(pairs[ATInterstitialAdLoadingExtra.kATInterstitialAdLoadingExtraInterstitialAdSizeStruct]);
pairs.Add(ATInterstitialAdLoadingExtra.kATInterstitialAdLoadingExtraInterstitialAdSize, size.width + "x" + size.height);
pairs.Add(ATInterstitialAdLoadingExtra.kATInterstitialAdSizeUsesPixelFlagKey, size.usesPixel);
client.loadInterstitialAd(placementId, JsonMapper.ToJson(pairs));
} else
{
client.loadInterstitialAd(placementId, JsonMapper.ToJson(pairs));
}
}
public bool hasInterstitialAdReady(string placementId)
{
return client.hasInterstitialAdReady(placementId);
}
public void entryScenarioWithPlacementID(string placementId, string scenarioID)
{
client.entryScenarioWithPlacementID(placementId,scenarioID);
}
public string checkAdStatus(string placementId)
{
return client.checkAdStatus(placementId);
}
public string getValidAdCaches(string placementId)
{
return client.getValidAdCaches(placementId);
}
public void showInterstitialAd(string placementId)
{
client.showInterstitialAd(placementId, JsonMapper.ToJson(new Dictionary<string, string>()));
}
public void showInterstitialAd(string placementId, Dictionary<string, string> pairs)
{
client.showInterstitialAd(placementId, JsonMapper.ToJson(pairs));
}
public IATInterstitialAdClient GetATInterstitialAdClient()
{
return AnyThinkAds.ATAdsClientFactory.BuildInterstitialAdClient();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9b93dd6d343c0473193c776c1ba89ec8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,74 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AnyThinkAds.Api
{
public interface ATInterstitialAdListener
{
/***
* 加载广告成功注意对于Android来说所有回调方法均不在Unity的主线程
* @param placementId 广告位id
*/
void onInterstitialAdLoad(string placementId);
/***
* 加载广告失败注意对于Android来说所有回调方法均不在Unity的主线程
* @param placementId 广告位id
* @param code 错误码
* @param message 错误信息
*/
void onInterstitialAdLoadFail(string placementId, string code, string message);
/***
* 广告展示注意对于Android来说所有回调方法均不在Unity的主线程
* @param placementId 广告位id
*/
void onInterstitialAdShow(string placementId, ATCallbackInfo callbackInfo);
/***
* 广告展示失败注意对于Android来说所有回调方法均不在Unity的主线程
* @param placementId 广告位id
*/
void onInterstitialAdFailedToShow(string placementId);
/***
* 广告关闭注意对于Android来说所有回调方法均不在Unity的主线程
* @param placementId 广告位id
*/
void onInterstitialAdClose(string placementId, ATCallbackInfo callbackInfo);
/***
* 广告点击注意对于Android来说所有回调方法均不在Unity的主线程
* @param placementId 广告位id
*/
void onInterstitialAdClick(string placementId, ATCallbackInfo callbackInfo);
/**
*广告开始播放视频注意对于Android来说所有回调方法均不在Unity的主线程
* @param placementId 广告位id
*/
void onInterstitialAdStartPlayingVideo(string placementId, ATCallbackInfo callbackInfo);
/**
*广告视频播放结束注意对于Android来说所有回调方法均不在Unity的主线程
* @param placementId 广告位id
*/
void onInterstitialAdEndPlayingVideo(string placementId, ATCallbackInfo callbackInfo);
/**
*广告播放视频失败注意对于Android来说所有回调方法均不在Unity的主线程
* @param placementId 广告位id
* @param code 错误码
* @param message 错误信息
*/
void onInterstitialAdFailedToPlayVideo(string placementId, string code, string message);
void startLoadingADSource(string placementId, ATCallbackInfo callbackInfo);
void finishLoadingADSource(string placementId, ATCallbackInfo callbackInfo);
void failToLoadADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message);
void startBiddingADSource(string placementId, ATCallbackInfo callbackInfo);
void finishBiddingADSource(string placementId, ATCallbackInfo callbackInfo);
void failBiddingADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d2b539b7c0e104683ad9789e63c426c1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,97 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
using System;
using AnyThinkAds.Common;
using AnyThinkAds.ThirdParty.LitJson;
namespace AnyThinkAds.Api
{
public class ATInterstitialAutoAd
{
private static readonly ATInterstitialAutoAd instance = new ATInterstitialAutoAd();
public IATInterstitialAdClient client;
private ATInterstitialAutoAd()
{
client = GetATInterstitialAdClient();
}
public static ATInterstitialAutoAd Instance
{
get
{
return instance;
}
}
public IATInterstitialAdClient GetATInterstitialAdClient()
{
return AnyThinkAds.ATAdsClientFactory.BuildInterstitialAdClient();
}
// auto
public void addAutoLoadAdPlacementID(string[] placementIDList)
{
client.addAutoLoadAdPlacementID(placementIDList);
}
public void removeAutoLoadAdPlacementID(string[] placementIDList)
{
if (placementIDList != null && placementIDList.Length > 0)
{
string placementIDListString = JsonMapper.ToJson(placementIDList);
client.removeAutoLoadAdPlacementID(placementIDListString);
Debug.Log("removeAutoLoadAdPlacementID, placementIDList === " + placementIDListString);
}
else
{
Debug.Log("removeAutoLoadAdPlacementID, placementIDList = null");
}
}
public string checkAutoAdStatus(string placementId)
{
return client.checkAutoAdStatus(placementId);
}
public bool autoLoadInterstitialAdReadyForPlacementID(string placementId)
{
return client.autoLoadInterstitialAdReadyForPlacementID(placementId);
}
public string getAutoValidAdCaches(string placementId)
{
return client.getAutoValidAdCaches(placementId);
}
public void setAutoLocalExtra(string placementId, Dictionary<string,string> pairs)
{
client.setAutoLocalExtra(placementId, JsonMapper.ToJson(pairs));
}
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID)
{
client.entryAutoAdScenarioWithPlacementID(placementId, scenarioID);
}
public void showAutoAd(string placementId)
{
client.showAutoAd(placementId, JsonMapper.ToJson(new Dictionary<string, string>()));
}
public void showAutoAd(string placementId, Dictionary<string, string> pairs)
{
client.showAutoAd(placementId, JsonMapper.ToJson(pairs));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5ec858a9445e344c6ae02b731012d297
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,101 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
using System;
using AnyThinkAds.Common;
using AnyThinkAds.ThirdParty.LitJson;
namespace AnyThinkAds.Api
{
public class ATNativeAdLoadingExtra
{
public static readonly string kATNativeAdLoadingExtraNativeAdSizeStruct = "native_ad_size_struct";
public static readonly string kATNativeAdLoadingExtraNativeAdSize = "native_ad_size";
public static readonly string kATNativeAdSizeUsesPixelFlagKey = "uses_pixel";
}
public class ATNativeAd
{
private static readonly ATNativeAd instance = new ATNativeAd();
public IATNativeAdClient client;
public ATNativeAd(){
client = GetATNativeAdClient();
}
public static ATNativeAd Instance
{
get
{
return instance;
}
}
public void loadNativeAd(string placementId, Dictionary<String,object> pairs){
if (pairs != null && pairs.ContainsKey(ATNativeAdLoadingExtra.kATNativeAdLoadingExtraNativeAdSizeStruct))
{
ATSize size = (ATSize)(pairs[ATNativeAdLoadingExtra.kATNativeAdLoadingExtraNativeAdSizeStruct]);
pairs.Add(ATNativeAdLoadingExtra.kATNativeAdLoadingExtraNativeAdSize, size.width + "x" + size.height);
pairs.Add(ATNativeAdLoadingExtra.kATNativeAdSizeUsesPixelFlagKey, size.usesPixel);
}
client.loadNativeAd(placementId,JsonMapper.ToJson(pairs));
}
public bool hasAdReady(string placementId){
return client.hasAdReady(placementId);
}
public string checkAdStatus(string placementId)
{
return client.checkAdStatus(placementId);
}
public string getValidAdCaches(string placementId)
{
return client.getValidAdCaches(placementId);
}
public void entryScenarioWithPlacementID(string placementId, string scenarioID)
{
client.entryScenarioWithPlacementID(placementId,scenarioID);
}
public void renderAdToScene(string placementId, ATNativeAdView anyThinkNativeAdView){
client.renderAdToScene(placementId, anyThinkNativeAdView, "");
}
public void renderAdToScene(string placementId, ATNativeAdView anyThinkNativeAdView, Dictionary<string,string> pairs){
client.renderAdToScene(placementId, anyThinkNativeAdView, JsonMapper.ToJson(pairs));
}
public void cleanAdView(string placementId, ATNativeAdView anyThinkNativeAdView){
client.cleanAdView(placementId, anyThinkNativeAdView);
}
public void onApplicationForces(string placementId, ATNativeAdView anyThinkNativeAdView){
client.onApplicationForces(placementId, anyThinkNativeAdView);
}
public void onApplicationPasue(string placementId, ATNativeAdView anyThinkNativeAdView){
client.onApplicationPasue(placementId, anyThinkNativeAdView);
}
public void cleanCache(string placementId){
client.cleanCache(placementId);
}
public IATNativeAdClient GetATNativeAdClient()
{
return AnyThinkAds.ATAdsClientFactory.BuildNativeAdClient();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 220e014333c6840fc89f951639f5deba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AnyThinkAds.Api
{
public interface ATNativeAdListener
{
/***
* 广告请求成功注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdLoaded(string placementId);
/***
* 广告请求失败注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdLoadFail(string placementId, string code, string message);
/***
* 广告展示注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdImpressed(string placementId, ATCallbackInfo callbackInfo);
/**
* 广告点击注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdClicked(string placementId, ATCallbackInfo callbackInfo);
/***
* 视屏播放开始 如果有注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdVideoStart(string placementId);
/***
* 视屏播放结束 如果有注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdVideoEnd(string placementId);
/***
* 视屏播放进度 如果有注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdVideoProgress(string placementId,int progress);
/***
* 广告关闭按钮点击 如果有注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdCloseButtonClicked(string placementId, ATCallbackInfo callbackInfo);
void startLoadingADSource(string placementId, ATCallbackInfo callbackInfo);
void finishLoadingADSource(string placementId, ATCallbackInfo callbackInfo);
void failToLoadADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message);
void startBiddingADSource(string placementId, ATCallbackInfo callbackInfo);
void finishBiddingADSource(string placementId, ATCallbackInfo callbackInfo);
void failBiddingADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a2c5ed4e8516545f0838dddae9200f2f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,103 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Text;
namespace AnyThinkAds.Api
{
public class ATNativeAdView
{
public ATNativeConfig config;
public ATNativeAdView(ATNativeConfig config)
{
this.config = config;
}
private string parentKey = "parent";
private string appIconKey = "appIcon";
private string mainImageKey = "mainImage";
private string titleKey = "title";
private string descKey = "desc";
private string adLogoKey = "adLogo";
private string ctaButtonKey = "cta";
private string dislikeButtonKey = "dislike";
public string toJSON()
{
StringBuilder builder = new StringBuilder();
builder.Append("{");
if(config.parentProperty != null)
{
builder.Append("\"").Append(parentKey).Append("\"");
builder.Append(":");
builder.Append(JsonUtility.ToJson(config.parentProperty));
builder.Append(",");
}
if(config.appIconProperty != null){
builder.Append("\"").Append(appIconKey).Append("\"");
builder.Append(":");
builder.Append(JsonUtility.ToJson(config.appIconProperty));
builder.Append(",");
}
if(config.mainImageProperty != null)
{
builder.Append("\"").Append(mainImageKey).Append("\"");
builder.Append(":");
builder.Append(JsonUtility.ToJson(config.mainImageProperty));
builder.Append(",");
}
if(config.titleProperty != null)
{
builder.Append("\"").Append(titleKey).Append("\"");
builder.Append(":");
builder.Append(JsonUtility.ToJson(config.titleProperty));
builder.Append(",");
}
if(config.descProperty != null)
{
builder.Append("\"").Append(descKey).Append("\"");
builder.Append(":");
builder.Append(JsonUtility.ToJson(config.descProperty));
builder.Append(",");
}
if(config.adLogoProperty != null)
{
builder.Append("\"").Append(adLogoKey).Append("\"");
builder.Append(":");
builder.Append(JsonUtility.ToJson(config.adLogoProperty));
builder.Append(",");
}
if(config.ctaButtonProperty != null)
{
builder.Append("\"").Append(ctaButtonKey).Append("\"");
builder.Append(":");
builder.Append(JsonUtility.ToJson(config.ctaButtonProperty));
builder.Append(",");
}
if(config.dislikeButtonProperty != null)
{
builder.Append("\"").Append(dislikeButtonKey).Append("\"");
builder.Append(":");
builder.Append(JsonUtility.ToJson(config.dislikeButtonProperty));
}
string temp = builder.ToString();
if (temp.EndsWith(","))
{
temp = temp.Substring(0, temp.Length - 1);
}
temp = temp + "}";
return temp;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 863e49baa0bfb4c899f6d1591f126aeb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,73 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
using System;
using AnyThinkAds.Common;
using AnyThinkAds.ThirdParty.LitJson;
namespace AnyThinkAds.Api
{
public class ATNativeBannerAdShowingExtra
{
public static readonly string kATNativeBannerAdShowingExtraBackgroundColor = "background_color";
public static readonly string kATNativeBannerAdShowingExtraAutorefreshInterval = "autorefresh_interval";
public static readonly string kATNativeBannerAdShowingExtraHideCloseButtonFlag = "hide_close_button_flag";
public static readonly string kATNativeBannerAdShowingExtraCTAButtonBackgroundColor = "cta_button_background_color";
public static readonly string kATNativeBannerAdShowingExtraCTATextColor = "cta_button_title_color";//of type string, example:#3e2f10
public static readonly string kATNativeBannerAdShowingExtraCTATextFont = "cta_text_font";//of type double
public static readonly string kATNativeBannerAdShowingExtraTitleColor = "title_color";
public static readonly string kATNativeBannerAdShowingExtraTitleFont = "title_font";
public static readonly string kATNativeBannerAdShowingExtraTextColor = "text_color";
public static readonly string kATNativeBannerAdShowingExtraTextFont = "text_font";
public static readonly string kATNativeBannerAdShowingExtraAdvertiserTextFont = "sponsor_text_font";
public static readonly string kATNativeBannerAdShowingExtraAdvertiserTextColor = "spnosor_text_color";
}
public class ATNativeBannerAd
{
private static readonly ATNativeBannerAd instance = new ATNativeBannerAd();
public IATNativeBannerAdClient client;
public ATNativeBannerAd() {
client = GetATNativeBannerAdClient();
}
public static ATNativeBannerAd Instance {
get {
return instance;
}
}
public void loadAd(string placementId, Dictionary<String, String> pairs) {
Debug.Log("ATNativeBannerAd::loadAd(" + placementId + ")");
client.loadAd(placementId, JsonMapper.ToJson(pairs));
}
public bool adReady(string placementId) {
Debug.Log("ATNativeBannerAd::adReady(" + placementId + ")");
return client.adReady(placementId);
}
public void setListener(ATNativeBannerAdListener listener) {
Debug.Log("ATNativeBannerAd::setListener");
client.setListener(listener);
}
public void showAd(string placementId, ATRect rect, Dictionary<string, string> pairs) {
Debug.Log("ATNativeBannerAd::showAd");
client.showAd(placementId, rect, pairs);
}
public void removeAd(string placementId) {
Debug.Log("ATNativeBannerAd::removeAd");
client.removeAd(placementId);
}
public IATNativeBannerAdClient GetATNativeBannerAdClient()
{
return AnyThinkAds.ATAdsClientFactory.BuildNativeBannerAdClient();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c4cf0c99e1e574b3aa6d4a1a46daf9da
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AnyThinkAds.Api
{
public interface ATNativeBannerAdListener
{
/***
* 广告请求成功注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdLoaded(string placementId);
/***
* 广告请求失败注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdLoadFail(string placementId, string code, string message);
/***
* 广告展示注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdImpressed(string placementId, ATCallbackInfo callbackInfo);
/**
* 广告点击注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdClicked(string placementId, ATCallbackInfo callbackInfo);
/**
* 广告自动刷新注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdAutoRefresh(string placementId, ATCallbackInfo callbackInfo);
/**
* 广告自动刷新失败注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdAutoRefreshFailure(string placementId, string code, string message);
/**
* 关闭按钮被点击内部逻辑不会移除ad view注意对于Android来说所有回调方法均不在Unity的主线程
*/
void onAdCloseButtonClicked(string placementId);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3f89a8b127b7346a7a27be7bf6cdc2a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AnyThinkAds.Api
{
public class ATNativeConfig
{
public ATNativeItemProperty parentProperty;
public ATNativeItemProperty appIconProperty;
public ATNativeItemProperty mainImageProperty;
public ATNativeItemProperty titleProperty;
public ATNativeItemProperty descProperty;
public ATNativeItemProperty adLogoProperty;
public ATNativeItemProperty ctaButtonProperty;
public ATNativeItemProperty dislikeButtonProperty;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7472931a01bd34107842d9baa5edf262
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AnyThinkAds.Api{
public class ATNativeItemProperty {
public int x;
public int y;
public int width;
public int height;
public bool usesPixel;
public string backgroundColor;
public string textColor; //只是针对text的view有效
public int textSize; //只是针对text的view有效
public bool isCustomClick; //只针对Android
public ATNativeItemProperty(int x, int y, int width, int height, string backgroundColor, string textColor, int textSize, bool usesPixel, bool isCustomClick)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.usesPixel = usesPixel;
this.backgroundColor = backgroundColor;
this.textColor = textColor;
this.textSize = textSize;
this.isCustomClick = isCustomClick;
}
public ATNativeItemProperty(int x, int y, int width, int height, string backgroundColor, string textColor, int textSize, bool usesPixel)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.usesPixel = usesPixel;
this.backgroundColor = backgroundColor;
this.textColor = textColor;
this.textSize = textSize;
}
public ATNativeItemProperty(int x,int y,int width,int height,string backgroundColor,string textColor,int textSize){
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.usesPixel = false;
this.backgroundColor = backgroundColor;
this.textColor = textColor;
this.textSize = textSize;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e4ce4b4690b764fcd9a5bdba6c7a48b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

55
AnyThinkAds/Api/ATRect.cs Normal file
View File

@@ -0,0 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AnyThinkAds.Api
{
public class ATRect
{
public ATRect(int x, int y, int width, int height, bool usesPixel)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.usesPixel = usesPixel;
}
public ATRect(int x, int y, int width, int height)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.usesPixel = false;
}
public int x = 0;
public int y = 0;
public int width = 0;
public int height = 0;
public bool usesPixel = false;
}
public class ATSize
{
public ATSize(int width, int height, bool usesPixel)
{
this.width = width;
this.height = height;
this.usesPixel = usesPixel;
}
public ATSize(int width, int height)
{
this.width = width;
this.height = height;
this.usesPixel = false;
}
public int width = 0;
public int height = 0;
public bool usesPixel = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8ce958c2c0a294f85981fc0d7efd277e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,93 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
using System;
using AnyThinkAds.Common;
using AnyThinkAds.ThirdParty.LitJson;
namespace AnyThinkAds.Api
{
public class ATRewardedAutoVideo
{
private static readonly ATRewardedAutoVideo instance = new ATRewardedAutoVideo();
public IATRewardedVideoAdClient client;
private ATRewardedAutoVideo()
{
client = GetATRewardedClient();
}
public static ATRewardedAutoVideo Instance
{
get
{
return instance;
}
}
// Auto
public void addAutoLoadAdPlacementID(string[] placementIDList)
{
client.addAutoLoadAdPlacementID(placementIDList);
}
public void removeAutoLoadAdPlacementID(string[] placementIDList)
{
if (placementIDList != null && placementIDList.Length > 0)
{
string placementIDListString = JsonMapper.ToJson(placementIDList);
client.removeAutoLoadAdPlacementID(placementIDListString);
Debug.Log("removeAutoLoadAdPlacementID, placementIDList === " + placementIDListString);
}
else
{
Debug.Log("removeAutoLoadAdPlacementID, placementIDList = null");
}
}
public bool autoLoadRewardedVideoReadyForPlacementID(string placementId)
{
return client.autoLoadRewardedVideoReadyForPlacementID(placementId);
}
public string getAutoValidAdCaches(string placementId)
{
return client.getAutoValidAdCaches(placementId);
}
public string checkAutoAdStatus(string placementId)
{
return client.checkAutoAdStatus(placementId);
}
public void setAutoLocalExtra(string placementId, Dictionary<string,string> pairs)
{
client.setAutoLocalExtra(placementId, JsonMapper.ToJson(pairs));
}
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID)
{
client.entryAutoAdScenarioWithPlacementID(placementId, scenarioID);
}
public void showAutoAd(string placementId)
{
client.showAutoAd(placementId, JsonMapper.ToJson(new Dictionary<string, string>()));
}
public void showAutoAd(string placementId, Dictionary<string, string> pairs)
{
client.showAutoAd(placementId, JsonMapper.ToJson(pairs));
}
public IATRewardedVideoAdClient GetATRewardedClient()
{
return AnyThinkAds.ATAdsClientFactory.BuildRewardedVideoAdClient();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5feccd0a003ab4defba25cd4e3f9e870
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,79 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
using System;
using AnyThinkAds.Common;
using AnyThinkAds.ThirdParty.LitJson;
namespace AnyThinkAds.Api
{
public class ATRewardedVideo
{
private static readonly ATRewardedVideo instance = new ATRewardedVideo();
public IATRewardedVideoAdClient client;
private ATRewardedVideo()
{
client = GetATRewardedClient();
}
public static ATRewardedVideo Instance
{
get
{
return instance;
}
}
/***
*
*/
public void loadVideoAd(string placementId, Dictionary<string,string> pairs)
{
client.loadVideoAd(placementId, JsonMapper.ToJson(pairs));
}
public bool hasAdReady(string placementId)
{
return client.hasAdReady(placementId);
}
public void entryScenarioWithPlacementID(string placementId, string scenarioID)
{
client.entryScenarioWithPlacementID(placementId,scenarioID);
}
public string checkAdStatus(string placementId)
{
return client.checkAdStatus(placementId);
}
public string getValidAdCaches(string placementId)
{
return client.getValidAdCaches(placementId);
}
public void showAd(string placementId)
{
client.showAd(placementId, JsonMapper.ToJson(new Dictionary<string, string>()));
}
public void showAd(string placementId, Dictionary<string, string> pairs)
{
client.showAd(placementId, JsonMapper.ToJson(pairs));
}
public IATRewardedVideoAdClient GetATRewardedClient()
{
return AnyThinkAds.ATAdsClientFactory.BuildRewardedVideoAdClient();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a1e0f021a24cc491eb4f054d576982f7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,90 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AnyThinkAds.Api
{
public interface ATRewardedVideoListener
{
/***
* The Ad load successfully (note: for Android, all callback methods are not in the main thread of Unity)
*/
void onRewardedVideoAdLoaded(string placementId);
/***
* The Ad load fail (note: for Android, all callback methods are not in the main thread of Unity)
*/
void onRewardedVideoAdLoadFail(string placementId,string code, string message);
/***
* The Ad play (note: for Android, all callback methods are not in the main thread of Unity)
*/
void onRewardedVideoAdPlayStart(string placementId, ATCallbackInfo callbackInfo);
/***
* The Ad play end (note: for Android, all callback methods are not in the main thread of Unity)
*/
void onRewardedVideoAdPlayEnd(string placementId, ATCallbackInfo callbackInfo);
/***
* The Ad play failnote: for Android, all callback methods are not in the main thread of Unity
* @param code error code
* @param message error message
*/
void onRewardedVideoAdPlayFail(string placementId,string code, string message);
/**
* The Ad closenote: for Android, all callback methods are not in the main thread of Unity
* @param isReward
*/
void onRewardedVideoAdPlayClosed(string placementId,bool isReward, ATCallbackInfo callbackInfo);
/***
* The Ad clicknote: for Android, all callback methods are not in the main thread of Unity
*/
void onRewardedVideoAdPlayClicked(string placementId, ATCallbackInfo callbackInfo);
/**
* The Ad rewardnote: for Android, all callback methods are not in the main thread of Unity
*/
void onReward(string placementId, ATCallbackInfo callbackInfo);
void startLoadingADSource(string placementId, ATCallbackInfo callbackInfo);
void finishLoadingADSource(string placementId, ATCallbackInfo callbackInfo);
void failToLoadADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message);
void startBiddingADSource(string placementId, ATCallbackInfo callbackInfo);
void finishBiddingADSource(string placementId, ATCallbackInfo callbackInfo);
void failBiddingADSource(string placementId,ATCallbackInfo callbackInfo,string code, string message);
}
public interface ATRewardedVideoExListener : ATRewardedVideoListener {
/***
* The Ad play again (note: for Android, all callback methods are not in the main thread of Unity)
*/
void onRewardedVideoAdAgainPlayStart(string placementId, ATCallbackInfo callbackInfo);
/***
* The Ad play end again(note: for Android, all callback methods are not in the main thread of Unity)
*/
void onRewardedVideoAdAgainPlayEnd(string placementId, ATCallbackInfo callbackInfo);
/***
* The Ad play fail again(note: for Android, all callback methods are not in the main thread of Unity)
*/
void onRewardedVideoAdAgainPlayFail(string placementId, string code, string message);
/***
* The Ad click again(note: for Android, all callback methods are not in the main thread of Unity)
*/
void onRewardedVideoAdAgainPlayClicked(string placementId, ATCallbackInfo callbackInfo);
/**
* The Ad reward again(note: for Android, all callback methods are not in the main thread of Unity)
*/
void onAgainReward(string placementId, ATCallbackInfo callbackInfo);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3c71cf6d83ff4406db7ed141066a54d3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

212
AnyThinkAds/Api/ATSDKAPI.cs Normal file
View File

@@ -0,0 +1,212 @@
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System;
using UnityEngine;
using AnyThinkAds.Common;
using AnyThinkAds.ThirdParty.LitJson;
namespace AnyThinkAds.Api
{
public interface ATGetUserLocationListener
{
void didGetUserLocation(int location);
}
public interface ATGetAreaListener
{
void onArea(string area);
void onError(string message);
}
public class ATSDKAPI
{
public static readonly int kATUserLocationUnknown = 0;
public static readonly int kATUserLocationInEU = 1;
public static readonly int kATUserLocationOutOfEU = 2;
public static readonly int PERSONALIZED = 0;
public static readonly int NONPERSONALIZED = 1;
public static readonly int UNKNOWN = 2;
public static readonly int AREA_GLOBAL = 0;
public static readonly int AREA_CHINESE_MAINLAND = 1;
//for android and ios
public static readonly string OS_VERSION_NAME = "os_vn";
public static readonly string OS_VERSION_CODE = "os_vc";
public static readonly string APP_PACKAGE_NAME = "package_name";
public static readonly string APP_VERSION_NAME = "app_vn";
public static readonly string APP_VERSION_CODE = "app_vc";
public static readonly string BRAND = "brand";
public static readonly string MODEL = "model";
public static readonly string DEVICE_SCREEN_SIZE = "screen";
public static readonly string MNC = "mnc";
public static readonly string MCC = "mcc";
public static readonly string LANGUAGE = "language";
public static readonly string TIMEZONE = "timezone";
public static readonly string USER_AGENT = "ua";
public static readonly string ORIENTATION = "orient";
public static readonly string NETWORK_TYPE = "network_type";
//for android
public static readonly string INSTALLER = "it_src";
public static readonly string ANDROID_ID = "android_id";
public static readonly string GAID = "gaid";
public static readonly string MAC = "mac";
public static readonly string IMEI = "imei";
public static readonly string OAID = "oaid";
//for ios
public static readonly string IDFA = "idfa";
public static readonly string IDFV = "idfv";
private static readonly IATSDKAPIClient client = GetATSDKAPIClient();
public static void initSDK(string appId, string appKey)
{
client.initSDK(appId, appKey);
}
public static void initSDK(string appId, string appKey, ATSDKInitListener listener)
{
client.initSDK(appId, appKey, listener);
}
public static void setGDPRLevel(int level)
{
client.setGDPRLevel(level);
}
public static void getUserLocation(ATGetUserLocationListener listener)
{
client.getUserLocation(listener);
}
public static int getGDPRLevel() {
return client.getGDPRLevel();
}
public static bool isEUTraffic() {
return client.isEUTraffic();
}
public static void setChannel(string channel)
{
client.setChannel(channel);
}
public static void setSubChannel(string subChannel)
{
client.setSubChannel(subChannel);
}
public static void initCustomMap(Dictionary<string, string> customMap)
{
client.initCustomMap(JsonMapper.ToJson(customMap));
}
public static void setCustomDataForPlacementID(Dictionary<string, string> customData, string placementID)
{
client.setCustomDataForPlacementID(JsonMapper.ToJson(customData), placementID);
}
public static void showGDPRAuth()
{
client.showGDPRAuth();
}
public static void setLogDebug(bool isDebug)
{
client.setLogDebug(isDebug);
}
public static void addNetworkGDPRInfo(int networkType, Dictionary<string,object> dictionary)
{
client.addNetworkGDPRInfo(networkType, JsonMapper.ToJson(dictionary));
}
public static void deniedUploadDeviceInfo(string[] deniedInfo)
{
if (deniedInfo != null && deniedInfo.Length > 0)
{
string deniedString = JsonMapper.ToJson(deniedInfo);
client.deniedUploadDeviceInfo(deniedString);
Debug.Log("deniedUploadDeviceInfo, deniedInfo === " + deniedString);
}
else
{
Debug.Log("deniedUploadDeviceInfo, deniedInfo = null");
}
}
private static IATSDKAPIClient GetATSDKAPIClient(){
Debug.Log("GetATSDKAPIClient");
return AnyThinkAds.ATAdsClientFactory.BuildSDKAPIClient();
}
public static void setExcludeBundleIdArray(string[] bundleIds)
{
if (bundleIds != null && bundleIds.Length > 0)
{
string bundleIdsString = JsonMapper.ToJson(bundleIds);
Debug.Log("setExcludeBundleIdArray, bundleIdsString === " + bundleIdsString);
client.setExcludeBundleIdArray(bundleIdsString);
}
else
{
Debug.Log("setExcludeBundleIdArray, bundleIdsString = null");
}
}
public static void setExcludeAdSourceIdArrayForPlacementID(string placementID, string[] adSourceIds)
{
if (adSourceIds != null && adSourceIds.Length > 0)
{
string adSourceIdsString = JsonMapper.ToJson(adSourceIds);
Debug.Log("setExcludeAdSourceIdArrayForPlacementID, adSourceIdsString === " + adSourceIdsString);
client.setExcludeAdSourceIdArrayForPlacementID(placementID, adSourceIdsString);
}
else
{
Debug.Log("setExcludeAdSourceIdArrayForPlacementID, adSourceIdsString = null");
}
}
public static void setSDKArea(int area)
{
client.setSDKArea(area);
}
public static void getArea(ATGetAreaListener listener)
{
client.getArea(listener);
}
public static void setWXStatus(bool install)
{
client.setWXStatus(install);
}
public static void setLocation(double longitude, double latitude)
{
client.setLocation(longitude, latitude);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 17ae30f8263a149fc8eba30dad68d0f0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AnyThinkAds.Api
{
public interface ATSDKInitListener
{
void initSuccess();
void initFail(string message);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 57b3ce41b10cf46cbb2e5a082691be6d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
AnyThinkAds/Common.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1e8456848ebbf4b988a66e831999e0b7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,75 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Api;
namespace AnyThinkAds.Common
{
public interface IATBannerAdClient : IATBannerEvents
{
/***
* 请求广告
* @param placementId 广告位id
* @parm mapJson 各平台的私有属性 一般可以不调用
*/
void loadBannerAd(string placementId, string mapJson);
/**
* 获取广告状态信息(是否正在加载、是否存在可以展示广告、广告缓存详细信息)
* @param unityid
*
*/
string checkAdStatus(string placementId);
/***
*
* 设置监听回调接口
*
* @param listener
*/
void setListener(ATBannerAdListener listener);
/***
*
* 展示广告,
* @param placementId
* @param pass bottom or top for position
* @parm mapJson
*/
void showBannerAd(string placementId, string position, string mapJson);
/***
*
* 展示广告,
* @param placementId
* @param rect the region used to show banner ad; currently only x&y fields in rect are used(as the origin, or top left corner of the banner).
* @parm mapJson
*/
void showBannerAd(string placementId, ATRect rect, string mapJson);
/***
*
* 清理广告
* @param placementId
* @param anyThinkNativeAdView 这里的属性是显示区域坐标等配置,需要自行设置
*/
void cleanBannerAd(string placementId);
/***
*
* 隐藏广告
* @param placementId
* @param rect the region used to show banner ad.
*/
void hideBannerAd(string placementId);
/***
*
* (重新)展示之前隐藏的广告
* @param placementId
*/
void showBannerAd(string placementId);
/***
* 清理缓存
*/
void cleanCache(string placementId);
/***
* 获取所有可用缓存广告
*/
string getValidAdCaches(string placementId);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 33f1ceabaff3f4892a39bf63a74352b7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@

using AnyThinkAds.Api;
namespace AnyThinkAds.Common
{
public interface IATDownloadClient
{
/**
* @param listener
*/
void setListener(ATDownloadAdListener listener);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9fd119e79e8154f6e885622336dd50f7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,64 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Api;
namespace AnyThinkAds.Common
{
public interface IATInterstitialAdClient : IATInterstitialAdEvents
{
/***
* 请求广告
* @param placementId 广告位id
* @parm mapJson 各平台的私有属性 一般可以不调用
*/
void loadInterstitialAd(string placementId, string mapJson);
/***
*
* 设置监听回调接口
*
* @param listener
*/
void setListener(ATInterstitialAdListener listener);
/**
* 是否存在可以展示的广告
* @param unityid
*/
bool hasInterstitialAdReady(string placementId);
/**
* 获取广告状态信息(是否正在加载、是否存在可以展示广告、广告缓存详细信息)
* @param unityid
*
*/
string checkAdStatus(string placementId);
/***
* 显示广告
*/
void showInterstitialAd(string placementId, string mapJson);
/***
* 获取所有可用缓存广告
*/
string getValidAdCaches(string placementId);
void entryScenarioWithPlacementID(string placementId, string scenarioID);
string checkAutoAdStatus(string placementId);
void addAutoLoadAdPlacementID(string[] placementIDList);
void removeAutoLoadAdPlacementID(string placementId);
bool autoLoadInterstitialAdReadyForPlacementID(string placementId);
string getAutoValidAdCaches(string placementId);
void setAutoLocalExtra(string placementId, string mapJson);
void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID);
void showAutoAd(string placementId, string mapJson);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e2d102c3a980f472fa20811ed609d085
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,73 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Api;
namespace AnyThinkAds.Common
{
public interface IATNativeAdClient : IATNativeAdEvents
{
/***
* 请求广告
* @param placementId 广告位id
* @parm mapJson 各平台的私有属性 一般可以不调用
*/
void loadNativeAd(string placementId, string mapJson);
/***
* 判断是否有广告存在
* 可以在显示广告之前调用
* @param placementId 广告位id
*/
bool hasAdReady(string placementId);
/**
* 获取广告状态信息(是否正在加载、是否存在可以展示广告、广告缓存详细信息)
* @param unityid
*
*/
string checkAdStatus(string placementId);
/***
*
* 设置监听回调接口
*
* @param listener
*/
void setListener(ATNativeAdListener listener);
/***
*
* 展示广告,
* @param placementId
* @param anyThinkNativeAdView 这里的属性是显示区域坐标等配置,需要自行设置
* @parm mapJson
*/
void renderAdToScene(string placementId, ATNativeAdView anyThinkNativeAdView, string mapJson);
/***
*
* 清理广告
* @param placementId
* @param anyThinkNativeAdView 这里的属性是显示区域坐标等配置,需要自行设置
*/
void cleanAdView(string placementId, ATNativeAdView anyThinkNativeAdView);
/***
* 页面显示
*/
void onApplicationForces(string placementId, ATNativeAdView anyThinkNativeAdView);
/***
* 页面隐藏
*/
void onApplicationPasue(string placementId, ATNativeAdView anyThinkNativeAdView);
/***
* 清理缓存
*/
void cleanCache(string placementId);
/***
* 获取所有可用缓存广告
*/
string getValidAdCaches(string placementId);
void entryScenarioWithPlacementID(string placementId, string scenarioID);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f2275de4a621e46b2b6a157d2c35ed7e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,45 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Api;
namespace AnyThinkAds.Common
{
public interface IATNativeBannerAdClient : IATNativeAdEvents
{
/***
* 请求广告
* @param placementId 广告位id
* @parm mapJson 各平台的私有属性 一般可以不调用
*/
void loadAd(string placementId, string mapJson);
/***
* 判断是否有广告存在
* 可以在显示广告之前调用
* @param placementId 广告位id
*/
bool adReady(string placementId);
/***
*
* 设置监听回调接口
*
* @param listener
*/
void setListener(ATNativeBannerAdListener listener);
/***
*
* 展示广告,
* @param placementId
* @param rect
*/
void showAd(string placementId, ATRect rect, Dictionary<string, string> pairs);
/***
*
* 移除广告
* @param placementId
*/
void removeAd(string placementId);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 87ae11b5cac0f4dbbb559cfed9dc531b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Api;
namespace AnyThinkAds.Common
{
public interface IATRewardedVideoAdClient : IATRewardedVideoEvents
{
/**
* 请求视屏广告
* @param placementId 广告位id
* @parm mapJson 平台私有参数 一般不些
*/
void loadVideoAd(string placementId, string mapJson);
/**
* @param listener 监听回调
*/
void setListener(ATRewardedVideoListener listener);
/**
* 是否存在可以展示的广告
* @param unityid
*
*/
bool hasAdReady(string placementId);
/**
* 获取广告状态信息(是否正在加载、是否存在可以展示广告、广告缓存详细信息)
* @param unityid
*
*/
string checkAdStatus(string placementId);
/***
* 显示广告
*/
void showAd(string placementId, string mapJson);
/***
* 获取所有可用缓存广告
*/
string getValidAdCaches(string placementId);
void entryScenarioWithPlacementID(string placementId, string scenarioID);
string checkAutoAdStatus(string placementId);
void addAutoLoadAdPlacementID(string[] placementIDList);
void removeAutoLoadAdPlacementID(string placementId);
bool autoLoadRewardedVideoReadyForPlacementID(string placementId);
string getAutoValidAdCaches(string placementId);
void setAutoLocalExtra(string placementId, string mapJson);
void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID);
void showAutoAd(string placementId, string mapJson);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1c8f90439b6de4b25b7fc5e8d62ec895
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Api;
namespace AnyThinkAds.Common
{
public interface IATSDKAPIClient
{
void initSDK(string appId, string appKey);
void initSDK(string appId, string appKey, ATSDKInitListener listener);
void getUserLocation(ATGetUserLocationListener listener);
void setGDPRLevel(int level);
void showGDPRAuth();
void addNetworkGDPRInfo(int networkType, string mapJson);
void setChannel(string channel);
void setSubChannel(string subchannel);
void initCustomMap(string cutomMap);
void setCustomDataForPlacementID(string customData, string placementID);
void setLogDebug(bool isDebug);
int getGDPRLevel();
bool isEUTraffic();
void deniedUploadDeviceInfo(string deniedInfo);
void setExcludeBundleIdArray(string bundleIds);
void setExcludeAdSourceIdArrayForPlacementID(string placementID, string adsourceIds);
void setSDKArea(int area);
void getArea(ATGetAreaListener listener);
void setWXStatus(bool install);
void setLocation(double longitude, double latitude);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 833dc348e2c4648f08a4791990328b24
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a94c7b266b79787429106afa2514e1bd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 204b06fd9e3f8604f8bc52ca1580d565
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 957bd8bc9cbce83459807a818f4bbc43
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 69c6ecb25ea2fc94bbae9adeba79f8ff
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2b40414c5bb92cc4591777b77d3d888e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8cf0d327cc346430caa11f4acd1f815e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,428 @@
using System;
using UnityEngine;
using AnyThinkAds.Api;
using AnyThinkAds.Common;
using System.Collections;
using System.Collections.Generic;
#pragma warning disable 0067
namespace AnyThinkAds
{
public class ATAdsClientFactory
{
public static IATBannerAdClient BuildBannerAdClient()
{
#if UNITY_EDITOR
// Testing UNITY_EDITOR first because the editor also responds to the currently
// selected platform.
#elif UNITY_ANDROID
return new AnyThinkAds.Android.ATBannerAdClient();
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
return new AnyThinkAds.iOS.ATBannerAdClient();
#else
#endif
return new UnityBannerClient();
}
public static IATInterstitialAdClient BuildInterstitialAdClient()
{
#if UNITY_EDITOR
// Testing UNITY_EDITOR first because the editor also responds to the currently
// selected platform.
#elif UNITY_ANDROID
return new AnyThinkAds.Android.ATInterstitialAdClient();
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
return new AnyThinkAds.iOS.ATInterstitialAdClient();
#else
#endif
return new UnityInterstitialClient();
}
public static IATNativeAdClient BuildNativeAdClient()
{
#if UNITY_EDITOR
// Testing UNITY_EDITOR first because the editor also responds to the currently
// selected platform.
#elif UNITY_ANDROID
return new AnyThinkAds.Android.ATNativeAdClient();
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
return new AnyThinkAds.iOS.ATNativeAdClient();
#else
#endif
return new UnityNativeAdClient();
}
public static IATNativeBannerAdClient BuildNativeBannerAdClient()
{
#if UNITY_EDITOR
// Testing UNITY_EDITOR first because the editor also responds to the currently
// selected platform.
#elif UNITY_ANDROID
return new AnyThinkAds.Android.ATNativeBannerAdClient();
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
return new AnyThinkAds.iOS.ATNativeBannerAdClient();
#else
#endif
return new UnityNativeBannerAdClient();
}
public static IATRewardedVideoAdClient BuildRewardedVideoAdClient()
{
#if UNITY_EDITOR
// Testing UNITY_EDITOR first because the editor also responds to the currently
// selected platform.
#elif UNITY_ANDROID
return new AnyThinkAds.Android.ATRewardedVideoAdClient();
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
return new AnyThinkAds.iOS.ATRewardedVideoAdClient();
#else
#endif
return new UnityRewardedVideoAdClient();
}
public static IATSDKAPIClient BuildSDKAPIClient()
{
Debug.Log("BuildSDKAPIClient");
#if UNITY_EDITOR
Debug.Log("Unity Editor");
// Testing UNITY_EDITOR first because the editor also responds to the currently
// selected platform.
#elif UNITY_ANDROID
return new AnyThinkAds.Android.ATSDKAPIClient();
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
Debug.Log("Unity:ATAdsClientFactory::Build iOS Client");
return new AnyThinkAds.iOS.ATSDKAPIClient();
#else
#endif
return new UnitySDKAPIClient();
}
public static IATDownloadClient BuildDownloadClient()
{
Debug.Log("BuildDownloadClient");
#if UNITY_EDITOR
Debug.Log("Unity Editor");
// Testing UNITY_EDITOR first because the editor also responds to the currently
// selected platform.
#elif UNITY_ANDROID
return new AnyThinkAds.Android.ATDownloadClient();
#else
#endif
return new UnityDownloadClient();
}
}
class UnitySDKAPIClient:IATSDKAPIClient
{
public void initSDK(string appId, string appkey){}
public void initSDK(string appId, string appkey, ATSDKInitListener listener){ }
public void getUserLocation(ATGetUserLocationListener listener){ }
public void setGDPRLevel(int level){ }
public void showGDPRAuth(){ }
public void addNetworkGDPRInfo(int networkType, string mapJson){ }
public void setChannel(string channel){ }
public void setSubChannel(string subchannel){ }
public void initCustomMap(string cutomMap){ }
public void setCustomDataForPlacementID(string customData, string placementID){ }
public void setLogDebug(bool isDebug){ }
public int getGDPRLevel(){ return ATSDKAPI.PERSONALIZED; }
public bool isEUTraffic() { return false; }
public void deniedUploadDeviceInfo(string deniedInfo) { }
public void setExcludeBundleIdArray(string bundleIds) { }
public void setExcludeAdSourceIdArrayForPlacementID(string placementID, string adsourceIds) { }
public void setSDKArea(int area) { }
public void getArea(ATGetAreaListener listener) { }
public void setWXStatus(bool install) { }
public void setLocation(double longitude, double latitude) { }
}
class UnityBannerClient:IATBannerAdClient
{
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
public event EventHandler<ATAdEventArgs> onAdClickEvent;
public event EventHandler<ATAdEventArgs> onAdAutoRefreshEvent;
public event EventHandler<ATAdErrorEventArgs> onAdAutoRefreshFailureEvent;
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
public event EventHandler<ATAdEventArgs> onAdCloseButtonTappedEvent;
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
ATBannerAdListener listener;
public void loadBannerAd(string unitId, string mapJson){
if(listener != null)
{
listener.onAdLoadFail(unitId, "-1", "Must run on Android or IOS platform!");
}
}
public void setListener(ATBannerAdListener listener)
{
this.listener = listener;
}
public string checkAdStatus(string unitId) { return ""; }
public void showBannerAd(string unitId, string position){ }
public void showBannerAd(string unitId, string position, string mapJson){ }
public void showBannerAd(string unitId, ATRect rect){ }
public void showBannerAd(string unitId, ATRect rect, string mapJson){ }
public void cleanBannerAd(string unitId){ }
public void hideBannerAd(string unitId){ }
public void showBannerAd(string unitId){ }
public void cleanCache(string unitId){}
public string getValidAdCaches(string unitId) { return ""; }
}
class UnityInterstitialClient : IATInterstitialAdClient
{
ATInterstitialAdListener listener;
#pragma warning disable 220
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdShowEvent;
public event EventHandler<ATAdErrorEventArgs> onAdShowFailureEvent;
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
public event EventHandler<ATAdEventArgs> onAdClickEvent;
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
public event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
public void loadInterstitialAd(string unitId, string mapJson){
if (listener != null)
{
listener.onInterstitialAdLoadFail(unitId, "-1", "Must run on Android or IOS platform!");
}
}
public void setListener(ATInterstitialAdListener listener){
this.listener = listener;
}
public bool hasInterstitialAdReady(string unitId) { return false; }
public string checkAdStatus(string unitId) { return ""; }
public void showInterstitialAd(string unitId, string mapJson){}
public void cleanCache(string unitId){}
public string getValidAdCaches(string unitId) { return ""; }
public void entryScenarioWithPlacementID(string placementId, string scenarioID){}
public void addAutoLoadAdPlacementID(string[] placementIDList) {}
public void removeAutoLoadAdPlacementID(string placementId){}
public bool autoLoadInterstitialAdReadyForPlacementID(string placementId){return false;}
public string getAutoValidAdCaches(string placementId){return "";}
public string checkAutoAdStatus(string unitId) { return ""; }
public void setAutoLocalExtra(string placementId, string mapJson){}
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID){}
public void showAutoAd(string placementId, string mapJson){}
}
class UnityNativeAdClient : IATNativeAdClient
{
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
public event EventHandler<ATAdEventArgs> onAdClickEvent;
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
public event EventHandler<ATAdProgressEventArgs> onAdVideoProgressEvent;
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
ATNativeAdListener listener;
public void loadNativeAd(string unitId, string mapJson){
if(listener != null)
{
listener.onAdLoadFail(unitId, "-1", "Must run on Android or IOS platform!");
}
}
public bool hasAdReady(string unitId) { return false; }
public string checkAdStatus(string unitId) { return ""; }
public string getValidAdCaches(string unitId) { return ""; }
public void entryScenarioWithPlacementID(string placementId, string scenarioID){}
public void setListener(ATNativeAdListener listener){
this.listener = listener;
}
public void renderAdToScene(string unitId, ATNativeAdView anyThinkNativeAdView){}
public void renderAdToScene(string unitId, ATNativeAdView anyThinkNativeAdView, string mapJson){}
public void cleanAdView(string unitId, ATNativeAdView anyThinkNativeAdView){}
public void onApplicationForces(string unitId, ATNativeAdView anyThinkNativeAdView){}
public void onApplicationPasue(string unitId, ATNativeAdView anyThinkNativeAdView){}
public void cleanCache(string unitId){}
public void setLocalExtra(string unitid, string mapJson){}
}
class UnityNativeBannerAdClient : IATNativeBannerAdClient
{
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
public event EventHandler<ATAdEventArgs> onAdClickEvent;
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
public event EventHandler<ATAdProgressEventArgs> onAdVideoProgressEvent;
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
ATNativeBannerAdListener listener;
public void loadAd(string unitId, string mapJson){
if(listener != null)
{
listener.onAdLoadFail(unitId, "-1", "Must run on Android or IOS platform!");
}
}
public bool adReady(string unitId) { return false; }
public void setListener(ATNativeBannerAdListener listener){
this.listener = listener;
}
public void showAd(string unitId, ATRect rect, Dictionary<string, string> pairs){}
public void removeAd(string unitId){}
}
class UnityRewardedVideoAdClient : IATRewardedVideoAdClient
{
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
public event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
public event EventHandler<ATAdRewardEventArgs> onAdVideoCloseEvent;
public event EventHandler<ATAdEventArgs> onAdClickEvent;
public event EventHandler<ATAdEventArgs> onRewardEvent;
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
public event EventHandler<ATAdEventArgs> onPlayAgainStart;
public event EventHandler<ATAdEventArgs> onPlayAgainEnd;
public event EventHandler<ATAdErrorEventArgs> onPlayAgainFailure;
public event EventHandler<ATAdEventArgs> onPlayAgainClick;
public event EventHandler<ATAdEventArgs> onPlayAgainReward;
ATRewardedVideoListener listener;
public void loadVideoAd(string unitId, string mapJson){
if (listener != null)
{
listener.onRewardedVideoAdLoadFail(unitId, "-1", "Must run on Android or IOS platform!");
}
}
public void setListener(ATRewardedVideoListener listener){
this.listener = listener;
}
public bool hasAdReady(string unitId) { return false; }
public string checkAdStatus(string unitId) { return ""; }
public string getValidAdCaches(string unitId) { return ""; }
public void entryScenarioWithPlacementID(string placementId, string scenarioID){}
public void showAd(string unitId, string mapJson){}
public void addAutoLoadAdPlacementID(string[] placementIDList) {}
public void removeAutoLoadAdPlacementID(string placementId){}
public bool autoLoadRewardedVideoReadyForPlacementID(string placementId){return false;}
public string getAutoValidAdCaches(string placementId){return "";}
public string checkAutoAdStatus(string unitId) { return ""; }
public void setAutoLocalExtra(string placementId, string mapJson){}
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID){}
public void showAutoAd(string placementId, string mapJson){}
}
class UnityDownloadClient : IATDownloadClient
{
public void setListener(ATDownloadAdListener listener)
{
Debug.Log("Must run on Android platform");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7cfc618d1f344493aa2c430c0ff5e8c3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3e06b6a7bea414435806d944b50c9238
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Api;
namespace AnyThinkAds.Android
{
public class ATAreaListener : AndroidJavaProxy
{
ATGetAreaListener mListener;
public ATAreaListener(ATGetAreaListener listener): base("com.anythink.unitybridge.sdkinit.AreaCallbackListener")
{
mListener = listener;
}
public void onResultCallback(string area)
{
if (mListener != null)
{
mListener.onArea(area);
}
}
public void onErrorCallback(string s)
{
if (mListener != null)
{
mListener.onError(s);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eadc3c4bb3f0f4260b1a97ff1d4c1cf7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,314 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Common;
using AnyThinkAds.Api;
#pragma warning disable 0067
namespace AnyThinkAds.Android
{
public class ATBannerAdClient : AndroidJavaProxy, IATBannerAdClient
{
private Dictionary<string, AndroidJavaObject> bannerHelperMap = new Dictionary<string, AndroidJavaObject>();
private ATBannerAdListener anyThinkListener;
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
// triggers when a banner ad has failed to load
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
// triggers when a banner ad generates an impression
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
// triggers when the user clicks a banner ad
public event EventHandler<ATAdEventArgs> onAdClickEvent;
// triggers when the ad refreshes
public event EventHandler<ATAdEventArgs> onAdAutoRefreshEvent;
// triggers when the ad fails to auto refresh
public event EventHandler<ATAdErrorEventArgs> onAdAutoRefreshFailureEvent;
// triggers when the banner ad is closed
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
// triggers when the users closes the ad via the button
public event EventHandler<ATAdEventArgs> onAdCloseButtonTappedEvent;
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
public ATBannerAdClient() : base("com.anythink.unitybridge.banner.BannerListener")
{
}
public void loadBannerAd(string placementId, string mapJson)
{
//如果不存在则直接创建对应广告位的helper
if(!bannerHelperMap.ContainsKey(placementId))
{
AndroidJavaObject bannerHelper = new AndroidJavaObject(
"com.anythink.unitybridge.banner.BannerHelper", this);
bannerHelper.Call("initBanner", placementId);
bannerHelperMap.Add(placementId, bannerHelper);
Debug.Log("ATBannerAdClient : no exit helper ,create helper ");
}
try
{
Debug.Log("ATBannerAdClient : loadBannerAd ");
bannerHelperMap[placementId].Call("loadBannerAd", mapJson);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATBannerAdClient : error."+e.Message);
}
}
public string checkAdStatus(string placementId)
{
string adStatusJsonString = "";
Debug.Log("ATBannerAdClient : checkAdStatus....");
try
{
if (bannerHelperMap.ContainsKey(placementId))
{
adStatusJsonString = bannerHelperMap[placementId].Call<string>("checkAdStatus");
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATBannerAdClient : error." + e.Message);
}
return adStatusJsonString;
}
public string getValidAdCaches(string placementId)
{
string validAdCachesString = "";
Debug.Log("ATBannerAdClient : getValidAdCaches....");
try
{
if (bannerHelperMap.ContainsKey(placementId))
{
validAdCachesString = bannerHelperMap[placementId].Call<string>("getValidAdCaches");
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATBannerAdClient : error." + e.Message);
}
return validAdCachesString;
}
public void setListener(ATBannerAdListener listener)
{
anyThinkListener = listener;
}
public void showBannerAd(string placementId, string position, string mapJson)
{
Debug.Log("ATBannerAdClient : showBannerAd by position" );
//todo
try
{
if (bannerHelperMap.ContainsKey(placementId))
{
this.bannerHelperMap[placementId].Call("showBannerAd", position, mapJson);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATBannerAdClient : error." + e.Message);
}
}
public void showBannerAd(string placementId, ATRect rect, string mapJson)
{
Debug.Log("ATBannerAdClient : showBannerAd " );
try{
if (bannerHelperMap.ContainsKey(placementId)) {
this.bannerHelperMap[placementId].Call ("showBannerAd", rect.x, rect.y, rect.width, rect.height, mapJson);
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATBannerAdClient : error."+e.Message);
}
}
public void cleanBannerAd(string placementId)
{
Debug.Log("ATBannerAdClient : cleanBannerAd" );
try{
if (bannerHelperMap.ContainsKey(placementId)) {
this.bannerHelperMap[placementId].Call ("cleanBannerAd");
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATBannerAdClient : error."+e.Message);
}
}
public void hideBannerAd(string placementId)
{
Debug.Log("ATBannerAdClient : hideBannerAd");
try
{
if (bannerHelperMap.ContainsKey(placementId))
{
this.bannerHelperMap[placementId].Call("hideBannerAd");
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATBannerAdClient : error." + e.Message);
}
}
//针对已有的进行展示,没有就调用该方法无效
public void showBannerAd(string placementId)
{
Debug.Log("ATBannerAdClient : showBannerAd ");
try
{
if (bannerHelperMap.ContainsKey(placementId))
{
this.bannerHelperMap[placementId].Call("showBannerAd");
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATBannerAdClient : error." + e.Message);
}
}
public void cleanCache(string placementId)
{
}
//广告加载成功
public void onBannerLoaded(string placementId)
{
Debug.Log("onBannerLoaded...unity3d.");
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
}
//广告加载失败
public void onBannerFailed(string placementId,string code, string error)
{
Debug.Log("onBannerFailed...unity3d.");
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, error, code));
}
//广告点击
public void onBannerClicked(string placementId, string callbackJson)
{
Debug.Log("onBannerClicked...unity3d.");
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
//广告展示
public void onBannerShow(string placementId, string callbackJson)
{
Debug.Log("onBannerShow...unity3d.");
onAdImpressEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
//广告关闭
public void onBannerClose(string placementId, string callbackJson)
{
Debug.Log("onBannerClose...unity3d.");
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
//广告关闭
public void onBannerAutoRefreshed(string placementId, string callbackJson)
{
Debug.Log("onBannerAutoRefreshed...unity3d.");
onAdAutoRefreshEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
//广告自动刷新失败
public void onBannerAutoRefreshFail(string placementId, string code, string msg)
{
Debug.Log("onBannerAutoRefreshFail...unity3d.");
onAdAutoRefreshFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, msg, code));
}
// Adsource Listener
public void onAdSourceBiddingAttempt(string placementId, string callbackJson)
{
Debug.Log("onAdSourceBiddingAttempt...unity3d." + placementId + "," + callbackJson);
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onAdSourceBiddingFilled(string placementId, string callbackJson)
{
Debug.Log("onAdSourceBiddingFilled...unity3d." + placementId + "," + callbackJson);
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onAdSourceBiddingFail(string placementId, string callbackJson, string code, string error)
{
Debug.Log("onAdSourceBiddingFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
}
public void onAdSourceAttempt(string placementId, string callbackJson)
{
Debug.Log("onAdSourceAttempt...unity3d." + placementId + "," + callbackJson);
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onAdSourceLoadFilled(string placementId, string callbackJson)
{
Debug.Log("onAdSourceLoadFilled...unity3d." + placementId + "," + callbackJson);
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onAdSourceLoadFail(string placementId, string callbackJson, string code, string error)
{
Debug.Log("onAdSourceLoadFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 92e8455090a784b949bd67df1b3fc530
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,93 @@
using UnityEngine;
using AnyThinkAds.Common;
using AnyThinkAds.Api;
namespace AnyThinkAds.Android
{
public class ATDownloadClient : AndroidJavaProxy,IATDownloadClient
{
private AndroidJavaObject downloadHelper;
private ATDownloadAdListener anyThinkListener;
public ATDownloadClient() : base("com.anythink.unitybridge.download.DownloadListener")
{
}
public void setListener(ATDownloadAdListener listener)
{
Debug.Log("ATDownloadClient : setListener");
anyThinkListener = listener;
if (downloadHelper == null)
{
downloadHelper = new AndroidJavaObject(
"com.anythink.unitybridge.download.DownloadHelper", this);
}
}
public void onDownloadStart(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
{
Debug.Log("onDownloadStart...unity3d.");
if(anyThinkListener != null){
anyThinkListener.onDownloadStart(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
}
}
public void onDownloadUpdate(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
{
Debug.Log("onDownloadUpdate...unity3d.");
if (anyThinkListener != null)
{
anyThinkListener.onDownloadUpdate(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
}
}
public void onDownloadPause(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
{
Debug.Log("onDownloadPause...unity3d.");
if (anyThinkListener != null)
{
anyThinkListener.onDownloadPause(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
}
}
public void onDownloadFinish(string placementId, string callbackJson, long totalBytes, string fileName, string appName)
{
Debug.Log("onDownloadFinish...unity3d.");
if (anyThinkListener != null)
{
anyThinkListener.onDownloadFinish(placementId, new ATCallbackInfo(callbackJson), totalBytes, fileName, appName);
}
}
public void onDownloadFail(string placementId, string callbackJson, long totalBytes, long currBytes, string fileName, string appName)
{
Debug.Log("onDownloadFail...unity3d.");
if (anyThinkListener != null)
{
anyThinkListener.onDownloadFail(placementId, new ATCallbackInfo(callbackJson), totalBytes, currBytes, fileName, appName);
}
}
public void onInstalled(string placementId, string callbackJson, string fileName, string appName)
{
Debug.Log("onInstalled...unity3d.");
if (anyThinkListener != null)
{
anyThinkListener.onInstalled(placementId, new ATCallbackInfo(callbackJson), fileName, appName);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 10ff201c4f54b4fce8f22229037070c4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,427 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Common;
using AnyThinkAds.Api;
using AnyThinkAds.ThirdParty.LitJson;
namespace AnyThinkAds.Android
{
public class ATInterstitialAdClient : AndroidJavaProxy,IATInterstitialAdClient
{
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdShowEvent;
public event EventHandler<ATAdErrorEventArgs> onAdShowFailureEvent;
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
public event EventHandler<ATAdEventArgs> onAdClickEvent;
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
public event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
private Dictionary<string, AndroidJavaObject> interstitialHelperMap = new Dictionary<string, AndroidJavaObject>();
//private AndroidJavaObject videoHelper;
private ATInterstitialAdListener anyThinkListener;
private AndroidJavaObject interstitialAutoAdHelper;
public ATInterstitialAdClient() : base("com.anythink.unitybridge.interstitial.InterstitialListener")
{
interstitialAutoAdHelper = new AndroidJavaObject("com.anythink.unitybridge.interstitial.InterstitialAutoAdHelper", this);
}
public void loadInterstitialAd(string placementId, string mapJson)
{
//如果不存在则直接创建对应广告位的helper
if(!interstitialHelperMap.ContainsKey(placementId))
{
AndroidJavaObject videoHelper = new AndroidJavaObject(
"com.anythink.unitybridge.interstitial.InterstitialHelper", this);
videoHelper.Call("initInterstitial", placementId);
interstitialHelperMap.Add(placementId, videoHelper);
Debug.Log("ATInterstitialAdClient : no exit helper ,create helper ");
}
try
{
Debug.Log("ATInterstitialAdClient : loadInterstitialAd ");
interstitialHelperMap[placementId].Call("loadInterstitialAd", mapJson);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
}
}
public void setListener(ATInterstitialAdListener listener)
{
anyThinkListener = listener;
}
public bool hasInterstitialAdReady(string placementId)
{
bool isready = false;
Debug.Log ("ATInterstitialAdClient : hasAdReady....");
try{
if (interstitialHelperMap.ContainsKey(placementId)) {
isready = interstitialHelperMap[placementId].Call<bool> ("isAdReady");
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
}
return isready;
}
public string checkAdStatus(string placementId)
{
string adStatusJsonString = "";
Debug.Log("ATInterstitialAdClient : checkAdStatus....");
try
{
if (interstitialHelperMap.ContainsKey(placementId))
{
adStatusJsonString = interstitialHelperMap[placementId].Call<string>("checkAdStatus");
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATInterstitialAdClient : error." + e.Message);
}
return adStatusJsonString;
}
public void entryScenarioWithPlacementID(string placementId, string scenarioID){
Debug.Log("ATInterstitialAdClient : entryScenarioWithPlacementID....");
try
{
if (interstitialHelperMap.ContainsKey(placementId))
{
interstitialHelperMap[placementId].Call("entryAdScenario", scenarioID);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATInterstitialAdClient entryScenarioWithPlacementID: error." + e.Message);
}
}
public string getValidAdCaches(string placementId)
{
string validAdCachesString = "";
Debug.Log("ATNativeAdClient : getValidAdCaches....");
try
{
if (interstitialHelperMap.ContainsKey(placementId))
{
validAdCachesString = interstitialHelperMap[placementId].Call<string>("getValidAdCaches");
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATNativeAdClient : error." + e.Message);
}
return validAdCachesString;
}
public void showInterstitialAd(string placementId, string jsonmap)
{
Debug.Log("ATInterstitialAdClient : showAd " );
try{
if (interstitialHelperMap.ContainsKey(placementId)) {
this.interstitialHelperMap[placementId].Call ("showInterstitialAd", jsonmap);
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
}
}
public void cleanCache(string placementId)
{
Debug.Log("ATInterstitialAdClient : clean" );
try{
if (interstitialHelperMap.ContainsKey(placementId)) {
this.interstitialHelperMap[placementId].Call ("clean");
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
}
}
public void onApplicationForces(string placementId)
{
Debug.Log ("onApplicationForces.... ");
try{
if (interstitialHelperMap.ContainsKey(placementId)) {
this.interstitialHelperMap[placementId].Call ("onResume");
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
}
}
public void onApplicationPasue(string placementId)
{
Debug.Log ("onApplicationPasue.... ");
try{
if (interstitialHelperMap.ContainsKey(placementId)) {
this.interstitialHelperMap[placementId].Call ("onPause");
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATInterstitialAdClient : error."+e.Message);
}
}
//广告加载成功
public void onInterstitialAdLoaded(string placementId)
{
Debug.Log("onInterstitialAdLoaded...unity3d.");
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
}
//广告加载失败
public void onInterstitialAdLoadFail(string placementId,string code, string error)
{
Debug.Log("onInterstitialAdFailed...unity3d.");
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, error, code));
}
//开始播放
public void onInterstitialAdVideoStart(string placementId, string callbackJson)
{
Debug.Log("onInterstitialAdPlayStart...unity3d.");
onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
//结束播放
public void onInterstitialAdVideoEnd(string placementId, string callbackJson)
{
Debug.Log("onInterstitialAdPlayEnd...unity3d.");
onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
//播放失败
public void onInterstitialAdVideoError(string placementId,string code, string error)
{
Debug.Log("onInterstitialAdPlayFailed...unity3d.");
onAdVideoFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, error, code));
}
//展示失败
public void OnInterstitialAdFailedToShow(string placementID) {
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdFailedToShow()");
onAdShowFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementID, "Failed to show video ad", "-1"));
}
//广告关闭
public void onInterstitialAdClose(string placementId, string callbackJson)
{
Debug.Log("onInterstitialAdClosed...unity3d.");
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
//广告点击
public void onInterstitialAdClicked(string placementId, string callbackJson)
{
Debug.Log("onInterstitialAdClicked...unity3d.");
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onInterstitialAdShow(string placementId, string callbackJson){
Debug.Log("onInterstitialAdShow...unity3d.");
onAdShowEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
// Adsource Listener
public void onAdSourceBiddingAttempt(string placementId, string callbackJson)
{
Debug.Log("onAdSourceBiddingAttempt...unity3d." + placementId + "," + callbackJson);
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onAdSourceBiddingFilled(string placementId, string callbackJson)
{
Debug.Log("onAdSourceBiddingFilled...unity3d." + placementId + "," + callbackJson);
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onAdSourceBiddingFail(string placementId, string callbackJson, string code, string error)
{
Debug.Log("onAdSourceBiddingFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
}
public void onAdSourceAttempt(string placementId, string callbackJson)
{
Debug.Log("onAdSourceAttempt...unity3d." + placementId + "," + callbackJson);
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onAdSourceLoadFilled(string placementId, string callbackJson)
{
Debug.Log("onAdSourceLoadFilled...unity3d." + placementId + "," + callbackJson);
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onAdSourceLoadFail(string placementId, string callbackJson, string code, string error)
{
Debug.Log("onAdSourceLoadFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
}
// Auto
public void addAutoLoadAdPlacementID(string[] placementIDList){
Debug.Log("Unity: ATInterstitialAdClient:addAutoLoadAdPlacementID()" + JsonMapper.ToJson(placementIDList));
try
{
interstitialAutoAdHelper.Call("addPlacementIds", JsonMapper.ToJson(placementIDList));
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("Unity: ATInterstitialAdClient addAutoLoadAdPlacementID: error." + e.Message);
}
}
public void removeAutoLoadAdPlacementID(string placementId)
{
Debug.Log("Unity: ATInterstitialAdClient:removeAutoLoadAdPlacementID()");
try
{
interstitialAutoAdHelper.Call("removePlacementIds", placementId);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("Unity: ATInterstitialAdClient removeAutoLoadAdPlacementID: error." + e.Message);
}
}
public bool autoLoadInterstitialAdReadyForPlacementID(string placementId)
{
Debug.Log("Unity: ATInterstitialAdClient:autoLoadInterstitialAdReadyForPlacementID()");
bool isready = false;
try
{
isready = interstitialAutoAdHelper.Call<bool>("isAdReady", placementId);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATInterstitialAdClient:autoLoadInterstitialAdReadyForPlacementID( : error." + e.Message);
}
return isready;
}
public string getAutoValidAdCaches(string placementId)
{
Debug.Log("Unity: ATInterstitialAdClient:getAutoValidAdCaches()");
string adStatusJsonString = "";
try
{
adStatusJsonString = interstitialAutoAdHelper.Call<string>("getValidAdCaches", placementId);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATInterstitialAdClient:getAutoValidAdCaches() : error." + e.Message);
}
return adStatusJsonString;
}
public void setAutoLocalExtra(string placementId, string mapJson)
{
Debug.Log("Unity: ATInterstitialAdClient:setAutoLocalExtra()");
try
{
interstitialAutoAdHelper.Call("setAdExtraData", placementId, mapJson);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATInterstitialAdClient:setAutoLocalExtra() : error." + e.Message);
}
}
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID)
{
Debug.Log("Unity: ATInterstitialAdClient:entryAutoAdScenarioWithPlacementID()");
try
{
interstitialAutoAdHelper.Call("entryAdScenario", placementId, scenarioID);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATInterstitialAdClient:entryAutoAdScenarioWithPlacementID() : error." + e.Message);
}
}
public void showAutoAd(string placementId, string mapJson)
{
Debug.Log("Unity: ATInterstitialAdClient::showAutoAd()");
try
{
interstitialAutoAdHelper.Call("show", placementId, mapJson);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("Unity: ATInterstitialAdClient:showAutoAd() : error." + e.Message);
}
}
public string checkAutoAdStatus(string placementId)
{
Debug.Log("Unity: ATInterstitialAdClient:checkAutoAdStatus() : checkAutoAdStatus....");
string adStatusJsonString = "";
try
{
adStatusJsonString = interstitialAutoAdHelper.Call<string>("checkAdStatus", placementId);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("Unity: ATInterstitialAdClient:checkAutoAdStatus() : error." + e.Message);
}
return adStatusJsonString;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3a5faa4e142aa43dbba381b1cef1eb7b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,54 @@
using UnityEngine;
using System.Collections;
#if UNITY_ANDROID
public class ATMsgTools
{
private AndroidJavaObject _Plugin;
public ATMsgTools ()
{
try{
if (Application.platform != RuntimePlatform.Android)
return;
_Plugin = new AndroidJavaObject ("com.anythink.unitybridge.MsgTools");
}catch(System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
}
}
public void printLogI (string msg)
{
try{
_Plugin.Call ("printLogI",msg);
}catch(System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
}
}
public void printMsg (string msg)
{
try{
_Plugin.Call ("pirntMsg",msg);
}catch(System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3f9a8f81e02c94851a16c544a4f2bca9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,342 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Common;
using AnyThinkAds.Api;
namespace AnyThinkAds.Android
{
public class ATNativeAdClient : AndroidJavaProxy, IATNativeAdClient
{
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
public event EventHandler<ATAdEventArgs> onAdClickEvent;
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
public event EventHandler<ATAdProgressEventArgs> onAdVideoProgressEvent;
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
private Dictionary<string, AndroidJavaObject> nativeAdHelperMap = new Dictionary<string, AndroidJavaObject>();
private ATNativeAdListener mlistener;
public ATNativeAdClient(): base("com.anythink.unitybridge.nativead.NativeListener")
{
}
public void loadNativeAd(string placementId, string mapJson)
{
Debug.Log ("loadNativeAd....jsonmap:"+mapJson);
if(!nativeAdHelperMap.ContainsKey(placementId)){
AndroidJavaObject nativeHelper = new AndroidJavaObject(
"com.anythink.unitybridge.nativead.NativeHelper", this);
nativeHelper.Call("initNative", placementId);
nativeAdHelperMap.Add(placementId, nativeHelper);
}
try{
if (nativeAdHelperMap.ContainsKey(placementId)) {
nativeAdHelperMap[placementId].Call ("loadNative",mapJson);
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATNativeAdClient : error."+e.Message);
}
}
public bool hasAdReady(string placementId)
{
bool isready = false;
Debug.Log ("hasAdReady....");
try{
if (nativeAdHelperMap.ContainsKey(placementId)) {
isready = nativeAdHelperMap[placementId].Call<bool> ("isAdReady");
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATNativeAdClient : error."+e.Message);
}
return isready;
}
public void entryScenarioWithPlacementID(string placementId, string scenarioID){
Debug.Log("ATNativeAdClient : entryScenarioWithPlacementID....");
try
{
if (nativeAdHelperMap.ContainsKey(placementId))
{
nativeAdHelperMap[placementId].Call("entryAdScenario", scenarioID);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATNativeAdClient entryScenarioWithPlacementID: error." + e.Message);
}
}
public string checkAdStatus(string placementId)
{
string adStatusJsonString = "";
Debug.Log("ATNativeAdClient : checkAdStatus....");
try
{
if (nativeAdHelperMap.ContainsKey(placementId))
{
adStatusJsonString = nativeAdHelperMap[placementId].Call<string>("checkAdStatus");
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATNativeAdClient : error." + e.Message);
}
return adStatusJsonString;
}
public string getValidAdCaches(string placementId)
{
string validAdCachesString = "";
Debug.Log("ATNativeAdClient : getValidAdCaches....");
try
{
if (nativeAdHelperMap.ContainsKey(placementId))
{
validAdCachesString = nativeAdHelperMap[placementId].Call<string>("getValidAdCaches");
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATNativeAdClient : error." + e.Message);
}
return validAdCachesString;
}
public void setListener(ATNativeAdListener listener)
{
mlistener = listener;
}
public void renderAdToScene(string placementId, ATNativeAdView anyThinkNativeAdView, string mapJson)
{
string showconfig = anyThinkNativeAdView.toJSON ();
//暂未实现 show
Debug.Log ("renderAdToScene....showconfig >>>:"+showconfig);
try{
if (nativeAdHelperMap.ContainsKey(placementId)) {
nativeAdHelperMap[placementId].Call ("show",showconfig, mapJson);
}
}catch(System.Exception e){
Debug.Log ("ATNativeAdClient : error."+e.Message);
System.Console.WriteLine("Exception caught: {0}", e);
}
}
public void cleanAdView(string placementId, ATNativeAdView anyThinkNativeAdView)
{
//
Debug.Log ("cleanAdView.... ");
try{
if (nativeAdHelperMap.ContainsKey(placementId)) {
nativeAdHelperMap[placementId].Call ("cleanView");
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATNativeAdClient : error."+e.Message);
}
}
public void onApplicationForces(string placementId, ATNativeAdView anyThinkNativeAdView)
{
Debug.Log ("onApplicationForces.... ");
try{
if (nativeAdHelperMap.ContainsKey(placementId)) {
nativeAdHelperMap[placementId].Call ("onResume");
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATNativeAdClient : error."+e.Message);
}
}
public void onApplicationPasue(string placementId, ATNativeAdView anyThinkNativeAdView)
{
Debug.Log ("onApplicationPasue.... ");
try{
if (nativeAdHelperMap.ContainsKey(placementId)) {
nativeAdHelperMap[placementId].Call ("onPause");
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATNativeAdClient : error."+e.Message);
}
}
public void cleanCache(string placementId)
{
Debug.Log ("cleanCache....");
try{
if (nativeAdHelperMap.ContainsKey(placementId)) {
nativeAdHelperMap[placementId].Call ("clean");
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATNativeAdClient : error."+e.Message);
}
}
/**
* 广告展示回调
*
* @param view
*/
public void onAdImpressed(string placementId, string callbackJson)
{
Debug.Log("onAdImpressed...unity3d.");
onAdImpressEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
/**
* 广告点击回调
*
* @param view
*/
public void onAdClicked(string placementId, string callbackJson)
{
Debug.Log("onAdClicked...unity3d.");
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
/**
* 广告视频开始回调
*
* @param view
*/
public void onAdVideoStart(string placementId)
{
Debug.Log("onAdVideoStart...unity3d.");
onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementId));
}
/**
* 广告视频结束回调
*
* @param view
*/
public void onAdVideoEnd(string placementId)
{
Debug.Log("onAdVideoEnd...unity3d.");
onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementId,""));
}
/**
* 广告视频进度回调
*
* @param view
*/
public void onAdVideoProgress(string placementId,int progress)
{
Debug.Log("onAdVideoProgress...progress[" + progress + "]");
onAdVideoProgressEvent?.Invoke(this, new ATAdProgressEventArgs(placementId,"",progress));
}
/**
* 广告视频进度回调
*
* @param view
*/
public void onAdCloseButtonClicked(string placementId, string callbackJson)
{
Debug.Log("onAdCloseButtonClicked...unity3d");
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
/**
* 广告加载成功
*/
public void onNativeAdLoaded(string placementId)
{
Debug.Log("onNativeAdLoaded...unity3d.");
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId,""));
}
/**
* 广告加载失败
*/
public void onNativeAdLoadFail(string placementId,string code, string msg)
{
Debug.Log("onNativeAdLoadFail...unity3d. code:" + code + " msg:" + msg);
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId,code,msg));
}
// Adsource Listener
public void onAdSourceBiddingAttempt(string placementId, string callbackJson)
{
Debug.Log("onAdSourceBiddingAttempt...unity3d." + placementId + "," + callbackJson);
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void onAdSourceBiddingFilled(string placementId, string callbackJson)
{
Debug.Log("onAdSourceBiddingFilled...unity3d." + placementId + "," + callbackJson);
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void onAdSourceBiddingFail(string placementId, string callbackJson, string code, string error)
{
Debug.Log("onAdSourceBiddingFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId,callbackJson,code,error));
}
public void onAdSourceAttempt(string placementId, string callbackJson)
{
Debug.Log("onAdSourceAttempt...unity3d." + placementId + "," + callbackJson);
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void onAdSourceLoadFilled(string placementId, string callbackJson)
{
Debug.Log("onAdSourceLoadFilled...unity3d." + placementId + "," + callbackJson);
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void onAdSourceLoadFail(string placementId, string callbackJson, string code, string error)
{
Debug.Log("onAdSourceLoadFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId,callbackJson,code,error));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7739e5e9b404f44fc8d2079f8f8a5423
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,91 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Common;
using AnyThinkAds.Api;
#pragma warning disable 0067
namespace AnyThinkAds.Android
{
public class ATNativeBannerAdClient :IATNativeBannerAdClient
{
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
public event EventHandler<ATAdEventArgs> onAdClickEvent;
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
public event EventHandler<ATAdProgressEventArgs> onAdVideoProgressEvent;
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
public ATNativeBannerAdClient() {
}
public void loadAd(string placementId, string mapJson) {
}
public bool adReady(string placementId) {
return false;
}
public void setListener(ATNativeBannerAdListener listener) {
}
public void showAd(string placementId, ATRect rect, Dictionary<string, string> pairs) {
}
public void removeAd(string placementId) {
}
public void onAdLoaded(string placementId) {
Debug.Log("ATNativeBannerAdClient::onAdLoaded()");
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
}
public void onAdLoadFail(string placementId, string code, string message) {
Debug.Log("ATNativeBannerAdClient::onAdLoadFail()");
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, "", code, message));
}
public void onAdImpressed(string placementId, string callbackJson) {
Debug.Log("ATNativeBannerAdClient::onAdImpressed()");
onAdImpressEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void onAdClicked(string placementId, string callbackJson) {
Debug.Log("ATNativeBannerAdClient::onAdClicked()");
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void onAdAutoRefresh(string placementId, string callbackJson) {
Debug.Log("ATNativeBannerAdClient::onAdAutoRefresh()");
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void onAdAutoRefreshFailure(string placementId, string code, string message) {
Debug.Log("ATNativeBannerAdClient::onAdAutoRefreshFailure()");
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, "", code, message));
}
public void onAdCloseButtonClicked(string placementId) {
Debug.Log("ATNativeBannerAdClient::onAdCloseButtonClicked()");
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3e7ad1dcac86142608df799cdeefe124
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Api;
namespace AnyThinkAds.Android
{
public class ATNetTrafficListener : AndroidJavaProxy
{
ATGetUserLocationListener mListener;
public ATNetTrafficListener(ATGetUserLocationListener listener): base("com.anythink.unitybridge.sdkinit.SDKEUCallbackListener")
{
mListener = listener;
}
public void onResultCallback(bool isEu)
{
if (mListener != null)
{
if (isEu)
{
mListener.didGetUserLocation(ATSDKAPI.kATUserLocationInEU);
}
else
{
mListener.didGetUserLocation(ATSDKAPI.kATUserLocationOutOfEU);
}
}
}
public void onErrorCallback(string s)
{
if (mListener != null)
{
mListener.didGetUserLocation(ATSDKAPI.kATUserLocationUnknown);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bc7832ca770c84f96ac1401368abb7dc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,416 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Common;
using AnyThinkAds.Api;
using AnyThinkAds.ThirdParty.LitJson;
namespace AnyThinkAds.Android
{
public class ATRewardedVideoAdClient : AndroidJavaProxy,IATRewardedVideoAdClient
{
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
public event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
public event EventHandler<ATAdRewardEventArgs> onAdVideoCloseEvent;
public event EventHandler<ATAdEventArgs> onAdClickEvent;
public event EventHandler<ATAdEventArgs> onRewardEvent;
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
public event EventHandler<ATAdEventArgs> onPlayAgainStart;
public event EventHandler<ATAdEventArgs> onPlayAgainEnd;
public event EventHandler<ATAdErrorEventArgs> onPlayAgainFailure;
public event EventHandler<ATAdEventArgs> onPlayAgainClick;
public event EventHandler<ATAdEventArgs> onPlayAgainReward;
private Dictionary<string, AndroidJavaObject> videoHelperMap = new Dictionary<string, AndroidJavaObject>();
private AndroidJavaObject videoAutoAdHelper;
//private AndroidJavaObject videoHelper;
private ATRewardedVideoListener anyThinkListener;
public ATRewardedVideoAdClient() : base("com.anythink.unitybridge.videoad.VideoListener")
{
videoAutoAdHelper = new AndroidJavaObject("com.anythink.unitybridge.videoad.VideoAutoAdHelper", this);
}
public void loadVideoAd(string placementId, string mapJson)
{
if(!videoHelperMap.ContainsKey(placementId))
{
AndroidJavaObject videoHelper = new AndroidJavaObject(
"com.anythink.unitybridge.videoad.VideoHelper", this);
videoHelper.Call("initVideo", placementId);
videoHelperMap.Add(placementId, videoHelper);
Debug.Log("ATRewardedVideoAdClient : no exit helper ,create helper ");
}
try
{
Debug.Log("ATRewardedVideoAdClient : loadVideoAd ");
videoHelperMap[placementId].Call("fillVideo", mapJson);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATRewardedVideoAdClient : error."+e.Message);
}
}
public void setListener(ATRewardedVideoListener listener)
{
anyThinkListener = listener;
}
public bool hasAdReady(string placementId)
{
bool isready = false;
Debug.Log ("ATRewardedVideoAdClient : hasAdReady....");
try{
if (videoHelperMap.ContainsKey(placementId)) {
isready = videoHelperMap[placementId].Call<bool> ("isAdReady");
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATRewardedVideoAdClient : error."+e.Message);
}
return isready;
}
public string checkAdStatus(string placementId)
{
string adStatusJsonString = "";
Debug.Log("ATRewardedVideoAdClient : checkAdStatus....");
try
{
if (videoHelperMap.ContainsKey(placementId))
{
adStatusJsonString = videoHelperMap[placementId].Call<string>("checkAdStatus");
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATRewardedVideoAdClient : error." + e.Message);
}
return adStatusJsonString;
}
public void entryScenarioWithPlacementID(string placementId, string scenarioID){
Debug.Log("ATRewardedVideoAdClient : entryScenarioWithPlacementID....");
try
{
if (videoHelperMap.ContainsKey(placementId))
{
videoHelperMap[placementId].Call("entryAdScenario", scenarioID);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATRewardedVideoAdClient entryScenarioWithPlacementID: error." + e.Message);
}
}
public string getValidAdCaches(string placementId)
{
string validAdCachesString = "";
Debug.Log("ATNativeAdClient : getValidAdCaches....");
try
{
if (videoHelperMap.ContainsKey(placementId))
{
validAdCachesString = videoHelperMap[placementId].Call<string>("getValidAdCaches");
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATNativeAdClient : error." + e.Message);
}
return validAdCachesString;
}
public void showAd(string placementId, string scenario)
{
Debug.Log("ATRewardedVideoAdClient : showAd " );
try{
if (videoHelperMap.ContainsKey(placementId)) {
this.videoHelperMap[placementId].Call ("showVideo", scenario);
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATRewardedVideoAdClient : error."+e.Message);
}
}
public void onRewardedVideoAdLoaded(string placementId)
{
Debug.Log("onRewardedVideoAdLoaded...unity3d.");
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
}
public void onRewardedVideoAdFailed(string placementId,string code, string error)
{
Debug.Log("onRewardedVideoAdFailed...unity3d.");
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, error, code));
}
public void onRewardedVideoAdPlayStart(string placementId, string callbackJson)
{
Debug.Log("onRewardedVideoAdPlayStart...unity3d.");
onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onRewardedVideoAdPlayEnd(string placementId, string callbackJson)
{
Debug.Log("onRewardedVideoAdPlayEnd...unity3d.");
onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onRewardedVideoAdPlayFailed(string placementId,string code, string error)
{
Debug.Log("onRewardedVideoAdPlayFailed...unity3d.");
onAdVideoFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, error, code));
}
public void onRewardedVideoAdClosed(string placementId,bool isRewarded, string callbackJson)
{
Debug.Log("onRewardedVideoAdClosed...unity3d.");
onAdVideoCloseEvent?.Invoke(this, new ATAdRewardEventArgs(placementId, callbackJson, isRewarded));
}
public void onRewardedVideoAdPlayClicked(string placementId, string callbackJson)
{
Debug.Log("onRewardedVideoAdPlayClicked...unity3d.");
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onReward(string placementId, string callbackJson)
{
Debug.Log("onReward...unity3d.");
onRewardEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onRewardedVideoAdAgainPlayStart(string placementId, string callbackJson)
{
Debug.Log("onRewardedVideoAdAgainPlayStart...unity3d.");
onPlayAgainStart?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onRewardedVideoAdAgainPlayEnd(string placementId, string callbackJson)
{
Debug.Log("onRewardedVideoAdAgainPlayEnd...unity3d.");
onPlayAgainEnd?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onRewardedVideoAdAgainPlayFailed(string placementId, string code, string error)
{
Debug.Log("onRewardedVideoAdAgainPlayFailed...unity3d.");
onPlayAgainFailure?.Invoke(this, new ATAdErrorEventArgs(placementId, error, code));
}
public void onRewardedVideoAdAgainPlayClicked(string placementId, string callbackJson)
{
Debug.Log("onRewardedVideoAdAgainPlayClicked...unity3d.");
onPlayAgainClick?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onAgainReward(string placementId, string callbackJson)
{
Debug.Log("onAgainReward...unity3d.");
onPlayAgainReward?.Invoke(this, new ATAdRewardEventArgs(placementId, callbackJson, true));
}
// Adsource Listener
public void onAdSourceBiddingAttempt(string placementId, string callbackJson)
{
Debug.Log("onAdSourceBiddingAttempt...unity3d."+ placementId + "," + callbackJson);
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onAdSourceBiddingFilled(string placementId, string callbackJson)
{
Debug.Log("onAdSourceBiddingFilled...unity3d." + placementId + "," + callbackJson);
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onAdSourceBiddingFail(string placementId, string callbackJson, string code, string error)
{
Debug.Log("onAdSourceBiddingFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, error, code));
}
public void onAdSourceAttempt(string placementId, string callbackJson)
{
Debug.Log("onAdSourceAttempt...unity3d." + placementId + "," + callbackJson);
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onAdSourceLoadFilled(string placementId, string callbackJson)
{
Debug.Log("onAdSourceLoadFilled...unity3d." + placementId + "," + callbackJson);
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void onAdSourceLoadFail(string placementId, string callbackJson, string code, string error)
{
Debug.Log("onAdSourceLoadFail...unity3d." + placementId + "," + code + "," + error + "," + callbackJson);
onAdSourceLoadFailureEvent?.Invoke(this,new ATAdErrorEventArgs(placementId, error, code));
}
// Auto
public void addAutoLoadAdPlacementID(string[] placementIDList){
Debug.Log("Unity: ATRewardedVideoAdClient:addAutoLoadAdPlacementID()" + JsonMapper.ToJson(placementIDList));
try
{
videoAutoAdHelper.Call("addPlacementIds", JsonMapper.ToJson(placementIDList));
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("Unity: ATRewardedVideoAdClient addAutoLoadAdPlacementID: error." + e.Message);
}
}
public void removeAutoLoadAdPlacementID(string placementId) {
Debug.Log("Unity: ATRewardedVideoAdClient:removeAutoLoadAdPlacementID()");
try
{
videoAutoAdHelper.Call("removePlacementIds", placementId);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("Unity: ATRewardedVideoAdClient removeAutoLoadAdPlacementID: error." + e.Message);
}
}
public bool autoLoadRewardedVideoReadyForPlacementID(string placementId)
{
Debug.Log("Unity: ATRewardedVideoAdClient:autoLoadRewardedVideoReadyForPlacementID()");
bool isready = false;
try
{
isready = videoAutoAdHelper.Call<bool>("isAdReady", placementId);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATRewardedVideoAdClient:autoLoadRewardedVideoReadyForPlacementID( : error." + e.Message);
}
return isready;
}
public string getAutoValidAdCaches(string placementId)
{
Debug.Log("Unity: ATRewardedVideoAdClient:getAutoValidAdCaches()");
string adStatusJsonString = "";
try
{
adStatusJsonString = videoAutoAdHelper.Call<string>("getValidAdCaches", placementId);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATRewardedVideoAdClient:getAutoValidAdCaches() : error." + e.Message);
}
return adStatusJsonString;
}
public void setAutoLocalExtra(string placementId, string mapJson)
{
Debug.Log("Unity: ATRewardedVideoAdClient:setAutoLocalExtra()");
try
{
videoAutoAdHelper.Call("setAdExtraData", placementId, mapJson);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATRewardedVideoAdClient:setAutoLocalExtra() : error." + e.Message);
}
}
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID)
{
Debug.Log("Unity: ATRewardedVideoAdClient:entryAutoAdScenarioWithPlacementID()");
try
{
videoAutoAdHelper.Call("entryAdScenario", placementId, scenarioID);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATRewardedVideoAdClient:entryAutoAdScenarioWithPlacementID() : error." + e.Message);
}
}
public void showAutoAd(string placementId, string mapJson) {
Debug.Log("Unity: ATRewardedVideoAdClient:showAutoAd()");
try
{
videoAutoAdHelper.Call("show", placementId, mapJson);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("Unity: ATRewardedVideoAdClient:showAutoAd() : error." + e.Message);
}
}
public string checkAutoAdStatus(string placementId)
{
Debug.Log("Unity: ATRewardedVideoAdClient:checkAutoAdStatus() : checkAutoAdStatus....");
string adStatusJsonString = "";
try
{
adStatusJsonString = videoAutoAdHelper.Call<string>("checkAdStatus", placementId);
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("Unity: ATRewardedVideoAdClient:checkAutoAdStatus() : error." + e.Message);
}
return adStatusJsonString;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f8d0bdf7098d34eb28d38fba39a47b0c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,361 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Common;
using AnyThinkAds.Api;
namespace AnyThinkAds.Android
{
public class ATSDKAPIClient : AndroidJavaProxy, IATSDKAPIClient
{
private AndroidJavaObject sdkInitHelper;
private ATSDKInitListener sdkInitListener;
public ATSDKAPIClient () : base("com.anythink.unitybridge.sdkinit.SDKInitListener")
{
this.sdkInitHelper = new AndroidJavaObject(
"com.anythink.unitybridge.sdkinit.SDKInitHelper", this);
}
public void initSDK(string appId, string appKey)
{
this.initSDK(appId, appKey, null);
}
public void initSDK(string appId, string appKey, ATSDKInitListener listener)
{
Debug.Log("initSDK....");
sdkInitListener = listener;
try
{
if (this.sdkInitHelper != null)
{
this.sdkInitHelper.Call("initAppliction", appId, appKey);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATSDKAPIClient : error."+e.Message);
}
}
public void getUserLocation(ATGetUserLocationListener listener)
{
ATNetTrafficListener netTrafficListener = new ATNetTrafficListener(listener);
try
{
if (this.sdkInitHelper != null)
{
this.sdkInitHelper.Call("checkIsEuTraffic", netTrafficListener);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATSDKAPIClient : error." + e.Message);
}
//implement getting location here
}
public void setGDPRLevel(int level)
{
Debug.Log ("setGDPRLevel....");
try{
if (this.sdkInitHelper != null) {
this.sdkInitHelper.Call ("setGDPRLevel",level);
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATSDKAPIClient : error."+e.Message);
}
}
public void showGDPRAuth()
{
Debug.Log ("showGDPRAuth....");
try{
if (this.sdkInitHelper != null) {
this.sdkInitHelper.Call ("showGDPRAuth");
}
}catch(System.Exception e){
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log ("ATSDKAPIClient : error."+e.Message);
}
}
public void setChannel(string channel)
{
Debug.Log("setChannel....");
try
{
if (this.sdkInitHelper != null)
{
this.sdkInitHelper.Call("setChannel", channel);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATSDKAPIClient : error." + e.Message);
}
}
public void setSubChannel(string subchannel)
{
Debug.Log("setSubChannel....");
try
{
if (this.sdkInitHelper != null)
{
this.sdkInitHelper.Call("setSubChannel", subchannel);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATSDKAPIClient : error." + e.Message);
}
}
public void initCustomMap(string jsonMap)
{
Debug.Log("initCustomMap....");
try
{
if (this.sdkInitHelper != null)
{
this.sdkInitHelper.Call("initCustomMap", jsonMap);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATSDKAPIClient : error." + e.Message);
}
}
public void setCustomDataForPlacementID(string customData, string placementID)
{
Debug.Log("setCustomDataForPlacementID....");
try
{
if (this.sdkInitHelper != null)
{
this.sdkInitHelper.Call("initPlacementCustomMap", placementID, customData);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATSDKAPIClient : error." + e.Message);
}
}
public void setLogDebug(bool isDebug)
{
Debug.Log("setLogDebug....");
try
{
if (this.sdkInitHelper != null)
{
this.sdkInitHelper.Call("setDebugLogOpen", isDebug);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATSDKAPIClient : error." + e.Message);
}
}
public void addNetworkGDPRInfo(int networkType, string mapJson)
{
// Debug.Log ("addNetworkGDPRInfo...." + networkType + "mapjson:"+mapJson);
// try{
// if (this.sdkInitHelper != null) {
// this.sdkInitHelper.Call ("addNetworkGDPRInfo",networkType,mapJson);
// }
// }catch(System.Exception e){
// System.Console.WriteLine("Exception caught: {0}", e);
// Debug.Log ("ATSDKAPIClient : error."+e.Message);
// }
}
public void initSDKSuccess(string appid)
{
Debug.Log("initSDKSuccess...unity3d.");
if(sdkInitListener != null){
sdkInitListener.initSuccess();
}
}
public void initSDKError(string appid, string message)
{
Debug.Log("initSDKError..unity3d..");
if (sdkInitListener != null)
{
sdkInitListener.initFail(message);
}
}
public int getGDPRLevel()
{
Debug.Log("getGDPRLevel....");
try
{
if (this.sdkInitHelper != null)
{
return this.sdkInitHelper.Call<int>("getGDPRLevel");
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATSDKAPIClient : error." + e.Message);
}
return 2; //UNKNOW
}
public bool isEUTraffic()
{
Debug.Log("isEUTraffic....");
try
{
if (this.sdkInitHelper != null)
{
return this.sdkInitHelper.Call<bool>("isEUTraffic");
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATSDKAPIClient : error." + e.Message);
}
return false;
}
public void deniedUploadDeviceInfo(string deniedInfoString)
{
Debug.Log("deniedUploadDeviceInfo....");
try
{
if (this.sdkInitHelper != null)
{
this.sdkInitHelper.Call("deniedUploadDeviceInfo", deniedInfoString);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATSDKAPIClient : error." + e.Message);
}
}
public void setExcludeBundleIdArray(string bundleIds)
{
Debug.Log("setExcludeBundleIdArray....");
try
{
if (this.sdkInitHelper != null)
{
this.sdkInitHelper.Call("setExcludeBundleIdArray", bundleIds);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATSDKAPIClient : error." + e.Message);
}
}
public void setExcludeAdSourceIdArrayForPlacementID(string placementID, string adsourceIds)
{
Debug.Log("setExcludeAdSourceIdArrayForPlacementID....");
try
{
if (this.sdkInitHelper != null)
{
this.sdkInitHelper.Call("setExcludeAdSourceIdArrayForPlacementID", placementID, adsourceIds);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATSDKAPIClient : error." + e.Message);
}
}
public void setSDKArea(int area)
{
Debug.Log("setSDKArea....");
try
{
if (this.sdkInitHelper != null)
{
this.sdkInitHelper.Call("setSDKArea", area);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATSDKAPIClient : error." + e.Message);
}
}
public void getArea(ATGetAreaListener listener)
{
Debug.Log("getArea....");
ATAreaListener areaListener = new ATAreaListener(listener);
try
{
if (this.sdkInitHelper != null)
{
this.sdkInitHelper.Call("getArea", areaListener);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATSDKAPIClient : error." + e.Message);
}
}
public void setWXStatus(bool install)
{
Debug.Log("setWXStatus....");
try
{
if (this.sdkInitHelper != null)
{
this.sdkInitHelper.Call("setWXStatus", install);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATSDKAPIClient : error." + e.Message);
}
}
public void setLocation(double longitude, double latitude)
{
Debug.Log("setLocation....");
try
{
if (this.sdkInitHelper != null)
{
this.sdkInitHelper.Call("setLocation", longitude, latitude);
}
}
catch (System.Exception e)
{
System.Console.WriteLine("Exception caught: {0}", e);
Debug.Log("ATSDKAPIClient : error." + e.Message);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 245e7a5e922934f43a6484d5f0189a91
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 24acb4405bd40449f82a6ea03b5824c7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,171 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Common;
using AnyThinkAds.Api;
using System;
namespace AnyThinkAds.iOS {
public class ATBannerAdClient : IATBannerAdClient {
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
public event EventHandler<ATAdEventArgs> onAdClickEvent;
public event EventHandler<ATAdEventArgs> onAdAutoRefreshEvent;
public event EventHandler<ATAdErrorEventArgs> onAdAutoRefreshFailureEvent;
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
public event EventHandler<ATAdEventArgs> onAdCloseButtonTappedEvent;
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
private ATBannerAdListener anyThinkListener;
public void addsetting(string placementId,string json){
//todo...
}
public void setListener(ATBannerAdListener listener) {
Debug.Log("Unity: ATBannerAdClient::setListener()");
anyThinkListener = listener;
}
public void loadBannerAd(string placementId, string mapJson) {
Debug.Log("Unity: ATBannerAdClient::loadBannerAd()");
ATBannerAdWrapper.setClientForPlacementID(placementId, this);
ATBannerAdWrapper.loadBannerAd(placementId, mapJson);
}
public string checkAdStatus(string placementId) {
Debug.Log("Unity: ATBannerAdClient::checkAdStatus()");
return ATBannerAdWrapper.checkAdStatus(placementId);
}
public string getValidAdCaches(string placementId)
{
Debug.Log("Unity: ATBannerAdClient::getValidAdCaches()");
return ATBannerAdWrapper.getValidAdCaches(placementId);
}
public void showBannerAd(string placementId, ATRect rect) {
Debug.Log("Unity: ATBannerAdClient::showBannerAd()");
ATBannerAdWrapper.showBannerAd(placementId, rect);
}
public void showBannerAd(string placementId, ATRect rect, string mapJson) {
Debug.Log("Unity: ATBannerAdClient::showBannerAd()");
ATBannerAdWrapper.showBannerAd(placementId, rect, mapJson);
}
public void showBannerAd(string placementId, string position)
{
Debug.Log("Unity: ATBannerAdClient::showBannerAd()");
ATBannerAdWrapper.showBannerAd(placementId, position);
}
public void showBannerAd(string placementId, string position, string mapJson)
{
Debug.Log("Unity: ATBannerAdClient::showBannerAd()");
ATBannerAdWrapper.showBannerAd(placementId, position, mapJson);
}
public void cleanBannerAd(string placementId) {
Debug.Log("Unity: ATBannerAdClient::cleanBannerAd()");
ATBannerAdWrapper.cleanBannerAd(placementId);
}
public void hideBannerAd(string placementId) {
Debug.Log("Unity: ATBannerAdClient::hideBannerAd()");
ATBannerAdWrapper.hideBannerAd(placementId);
}
public void showBannerAd(string placementId) {
Debug.Log("Unity: ATBannerAdClient::showBannerAd()");
ATBannerAdWrapper.showBannerAd(placementId);
}
public void cleanCache(string placementId) {
Debug.Log("Unity: ATBannerAdClient::cleanCache()");
ATBannerAdWrapper.clearCache();
}
public void OnBannerAdLoad(string placementId) {
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdLoad()");
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
}
public void OnBannerAdLoadFail(string placementId, string code, string message) {
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdLoadFail()");
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, message, code));
}
public void OnBannerAdImpress(string placementId, string callbackJson) {
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdImpress()");
onAdImpressEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void OnBannerAdClick(string placementId, string callbackJson) {
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdClick()");
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void OnBannerAdAutoRefresh(string placementId, string callbackJson) {
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdAutoRefresh()");
onAdAutoRefreshEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void OnBannerAdAutoRefreshFail(string placementId, string code, string message) {
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdAutoRefreshFail()");
onAdAutoRefreshFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, message, code));
}
public void OnBannerAdClose(string placementId) {
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdClose()");
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId));
}
public void OnBannerAdCloseButtonTapped(string placementId, string callbackJson) {
Debug.Log("Unity: HBBannerAdWrapper::OnBannerAdCloseButton()");
onAdCloseButtonTappedEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
//auto callbacks
public void startLoadingADSource(string placementId, string callbackJson)
{
Debug.Log("Unity: HBBannerAdWrapper::startLoadingADSource()");
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void finishLoadingADSource(string placementId, string callbackJson)
{
Debug.Log("Unity: HBBannerAdWrapper::finishLoadingADSource()");
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void failToLoadADSource(string placementId,string callbackJson, string code, string error)
{
Debug.Log("Unity: HBBannerAdWrapper::failToLoadADSource()");
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
}
public void startBiddingADSource(string placementId, string callbackJson)
{
Debug.Log("Unity: HBBannerAdWrapper::startBiddingADSource()");
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void finishBiddingADSource(string placementId, string callbackJson)
{
Debug.Log("Unity: HBBannerAdWrapper::finishBiddingADSource()");
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void failBiddingADSource(string placementId, string callbackJson,string code, string error)
{
Debug.Log("Unity: HBBannerAdWrapper::failBiddingADSource()");
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fc5aeee813f974653b6b9947425ec275
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,221 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Common;
using AnyThinkAds.Api;
using AnyThinkAds.ThirdParty.LitJson;
namespace AnyThinkAds.iOS {
public class ATInterstitialAdClient : IATInterstitialAdClient {
private ATInterstitialAdListener anyThinkListener;
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdShowEvent;
public event EventHandler<ATAdErrorEventArgs> onAdShowFailureEvent;
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
public event EventHandler<ATAdEventArgs> onAdClickEvent;
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
public event EventHandler<ATAdErrorEventArgs> onAdVideoFailureEvent;
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
public void addsetting(string placementId,string json){
//todo...
}
public void setListener(ATInterstitialAdListener listener) {
Debug.Log("Unity: ATInterstitialAdClient::setListener()");
anyThinkListener = listener;
}
public void loadInterstitialAd(string placementId, string mapJson) {
Debug.Log("Unity: ATInterstitialAdClient::loadInterstitialAd()");
ATInterstitialAdWrapper.setClientForPlacementID(placementId, this);
ATInterstitialAdWrapper.loadInterstitialAd(placementId, mapJson);
}
public bool hasInterstitialAdReady(string placementId) {
Debug.Log("Unity: ATInterstitialAdClient::hasInterstitialAdReady()");
return ATInterstitialAdWrapper.hasInterstitialAdReady(placementId);
}
public void showInterstitialAd(string placementId, string mapJson) {
Debug.Log("Unity: ATInterstitialAdClient::showInterstitialAd()");
ATInterstitialAdWrapper.showInterstitialAd(placementId, mapJson);
}
public void cleanCache(string placementId) {
Debug.Log("Unity: ATInterstitialAdClient::cleanCache()");
ATInterstitialAdWrapper.clearCache(placementId);
}
public string checkAdStatus(string placementId) {
Debug.Log("Unity: ATInterstitialAdClient::checkAdStatus()");
return ATInterstitialAdWrapper.checkAdStatus(placementId);
}
public string getValidAdCaches(string placementId)
{
Debug.Log("Unity: ATInterstitialAdClient::getValidAdCaches()");
return ATInterstitialAdWrapper.getValidAdCaches(placementId);
}
public void entryScenarioWithPlacementID(string placementId, string scenarioID){
Debug.Log("Unity: ATInterstitialAdClient::entryScenarioWithPlacementID()");
ATInterstitialAdWrapper.entryScenarioWithPlacementID(placementId,scenarioID);
}
//Callbacks
public void OnInterstitialAdLoaded(string placementID) {
Debug.Log("onInterstitialAdLoaded...unity3d.");
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementID));
}
public void OnInterstitialAdLoadFailure(string placementID, string code, string error) {
Debug.Log("onInterstitialAdFailed...unity3d.");
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementID, error, code));
}
public void OnInterstitialAdVideoPlayFailure(string placementID, string code, string error) {
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdVideoPlayFailure()");
onAdVideoFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementID, error, code));
}
public void OnInterstitialAdVideoPlayStart(string placementID, string callbackJson) {
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdPlayStart()");
onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
}
public void OnInterstitialAdVideoPlayEnd(string placementID, string callbackJson) {
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdVideoPlayEnd()");
onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
}
public void OnInterstitialAdShow(string placementID, string callbackJson) {
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdShow()");
onAdShowEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
}
public void OnInterstitialAdFailedToShow(string placementID) {
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdFailedToShow()");
onAdShowFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementID, "Failed to show video ad", "-1"));
}
public void OnInterstitialAdClick(string placementID, string callbackJson) {
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdClick()");
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
}
public void OnInterstitialAdClose(string placementID, string callbackJson) {
Debug.Log("Unity: ATInterstitialAdClient::OnInterstitialAdClose()");
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementID, callbackJson));
}
//auto callbacks
public void startLoadingADSource(string placementId, string callbackJson)
{
Debug.Log("Unity: ATInterstitialAdClient::startLoadingADSource()");
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void finishLoadingADSource(string placementId, string callbackJson)
{
Debug.Log("Unity: ATInterstitialAdClient::finishLoadingADSource()");
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void failToLoadADSource(string placementId, string callbackJson,string code, string error)
{
Debug.Log("Unity: ATInterstitialAdClient::failToLoadADSource()");
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
}
public void startBiddingADSource(string placementId, string callbackJson)
{
Debug.Log("Unity: ATInterstitialAdClient::startBiddingADSource()");
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void finishBiddingADSource(string placementId, string callbackJson)
{
Debug.Log("Unity: ATInterstitialAdClient::finishBiddingADSource()");
onAdSourceBiddingFilledEvent?.Invoke(this, new ATAdEventArgs(placementId, callbackJson));
}
public void failBiddingADSource(string placementId,string callbackJson, string code, string error)
{
Debug.Log("Unity: ATInterstitialAdClient::failBiddingADSource()");
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, callbackJson, code, error));
}
// Auto
public void addAutoLoadAdPlacementID(string[] placementIDList)
{
Debug.Log("Unity: ATInterstitialAdClient:addAutoLoadAdPlacementID()");
if (placementIDList != null && placementIDList.Length > 0)
{
foreach (string placementID in placementIDList)
{
ATInterstitialAdWrapper.setClientForPlacementID(placementID, this);
}
string placementIDListString = JsonMapper.ToJson(placementIDList);
ATInterstitialAdWrapper.addAutoLoadAdPlacementID(placementIDListString);
Debug.Log("addAutoLoadAdPlacementID, placementIDList === " + placementIDListString);
}
else
{
Debug.Log("addAutoLoadAdPlacementID, placementIDList = null");
}
}
public void removeAutoLoadAdPlacementID(string placementId)
{
Debug.Log("Unity: ATInterstitialAdClient:removeAutoLoadAdPlacementID()");
ATInterstitialAdWrapper.removeAutoLoadAdPlacementID(placementId);
}
public bool autoLoadInterstitialAdReadyForPlacementID(string placementId)
{
Debug.Log("Unity: ATInterstitialAdClient:autoLoadInterstitialAdReadyForPlacementID()");
return ATInterstitialAdWrapper.autoLoadInterstitialAdReadyForPlacementID(placementId);
}
public string getAutoValidAdCaches(string placementId)
{
Debug.Log("Unity: ATInterstitialAdClient:getAutoValidAdCaches()");
return ATInterstitialAdWrapper.getAutoValidAdCaches(placementId);
}
public string checkAutoAdStatus(string placementId) {
Debug.Log("Unity: ATInterstitialAdClient::checkAutoAdStatus()");
return ATInterstitialAdWrapper.checkAutoAdStatus(placementId);
}
public void setAutoLocalExtra(string placementId, string mapJson)
{
Debug.Log("Unity: ATInterstitialAdClient:setAutoLocalExtra()");
ATInterstitialAdWrapper.setAutoLocalExtra(placementId, mapJson);
}
public void entryAutoAdScenarioWithPlacementID(string placementId, string scenarioID)
{
Debug.Log("Unity: ATInterstitialAdClient:entryAutoAdScenarioWithPlacementID()");
ATInterstitialAdWrapper.entryAutoAdScenarioWithPlacementID(placementId, scenarioID);
}
public void showAutoAd(string placementId, string mapJson)
{
Debug.Log("Unity: ATInterstitialAdClient::showAutoAd()");
ATInterstitialAdWrapper.showAutoInterstitialAd(placementId, mapJson);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b16f7157dd7a84fbfa1a693d79e37e3e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,182 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Common;
using AnyThinkAds.Api;
using AnyThinkAds.iOS;
using AnyThinkAds.ThirdParty.LitJson;
#pragma warning disable 0067
namespace AnyThinkAds.iOS {
public class ATNativeAdClient : IATNativeAdClient {
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
public event EventHandler<ATAdEventArgs> onAdClickEvent;
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
public event EventHandler<ATAdProgressEventArgs> onAdVideoProgressEvent;
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
private ATNativeAdListener mlistener;
public void loadNativeAd(string placementId, string mapJson) {
Debug.Log("Unity:ATNativeAdClient::loadNativeAd()");
ATNativeAdWrapper.setClientForPlacementID(placementId, this);
ATNativeAdWrapper.loadNativeAd(placementId, mapJson);
}
public void setLocalExtra (string placementId,string localExtra){
}
public bool hasAdReady(string placementId) {
Debug.Log("Unity:ATNativeAdClient::hasAdReady()");
return ATNativeAdWrapper.isNativeAdReady(placementId);
}
public string checkAdStatus(string placementId) {
Debug.Log("Unity: ATNativeAdClient::checkAdStatus()");
return ATNativeAdWrapper.checkAdStatus(placementId);
}
public void entryScenarioWithPlacementID(string placementId, string scenarioID){
Debug.Log("Unity: ATNativeAdClient::entryScenarioWithPlacementID()");
ATNativeAdWrapper.entryScenarioWithPlacementID(placementId,scenarioID);
}
public string getValidAdCaches(string placementId)
{
Debug.Log("Unity: ATNativeAdClient::getValidAdCaches()");
return ATNativeAdWrapper.getValidAdCaches(placementId);
}
public void setListener(ATNativeAdListener listener) {
Debug.Log("Unity:ATNativeAdClient::setListener()");
mlistener = listener;
}
public void renderAdToScene(string placementId, ATNativeAdView anyThinkNativeAdView) {
Debug.Log("Unity:ATNativeAdClient::renderAdToScene()");
ATNativeAdWrapper.showNativeAd(placementId, anyThinkNativeAdView.toJSON());
}
public void renderAdToScene(string placementId, ATNativeAdView anyThinkNativeAdView, string mapJson) {
Debug.Log("Unity:ATNativeAdClient::renderAdToScene()");
ATNativeAdWrapper.showNativeAd(placementId, anyThinkNativeAdView.toJSON(), mapJson);
}
public void cleanAdView(string placementId, ATNativeAdView anyThinkNativeAdView) {
Debug.Log("Unity:ATNativeAdClient::cleanAdView()");
ATNativeAdWrapper.removeNativeAdView(placementId);
}
public void onApplicationForces(string placementId, ATNativeAdView anyThinkNativeAdView) {
Debug.Log("Unity:ATNativeAdClient::onApplicationForces()");
}
public void onApplicationPasue(string placementId, ATNativeAdView anyThinkNativeAdView) {
Debug.Log("Unity:ATNativeAdClient::onApplicationPasue()");
}
public void cleanCache(string placementId) {
Debug.Log("Unity:ATNativeAdClient::cleanCache()");
ATNativeAdWrapper.clearCache();
}
//Callbacks
public void onAdImpressed(string placementId, string callbackJson) {
Debug.Log("Unity:ATNativeAdClient::onAdImpressed...unity3d.");
onAdImpressEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void onAdClicked(string placementId, string callbackJson) {
Debug.Log("Unity:ATNativeAdClient::onAdClicked...unity3d.");
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void onAdCloseButtonClicked(string placementId, string callbackJson)
{
Debug.Log("Unity:ATNativeAdClient::onAdCloseButtonClicked...unity3d.");
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void onAdVideoStart(string placementId) {
Debug.Log("Unity:ATNativeAdClient::onAdVideoStart...unity3d.");
onAdVideoStartEvent?.Invoke(this, new ATAdEventArgs(placementId));
}
public void onAdVideoEnd(string placementId) {
Debug.Log("Unity:ATNativeAdClient::onAdVideoEnd...unity3d.");
onAdVideoEndEvent?.Invoke(this, new ATAdEventArgs(placementId,""));
}
public void onAdVideoProgress(string placementId,int progress) {
Debug.Log("Unity:ATNativeAdClient::onAdVideoProgress...progress[" + progress + "]");
onAdVideoProgressEvent?.Invoke(this, new ATAdProgressEventArgs(placementId,"",progress));
}
public void onNativeAdLoaded(string placementId) {
Debug.Log("Unity:ATNativeAdClient::onNativeAdLoaded...unity3d.");
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId,""));
}
public void onNativeAdLoadFail(string placementId,string code, string msg) {
Debug.Log("Unity:ATNativeAdClient::onNativeAdLoadFail...unity3d. code:" + code + " msg:" + msg);
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId,code,msg));
}
//auto callbacks
public void startLoadingADSource(string placementId, string callbackJson)
{
Debug.Log("Unity: ATNativeAdClient::startLoadingADSource()");
onAdSourceAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void finishLoadingADSource(string placementId, string callbackJson)
{
Debug.Log("Unity: ATNativeAdClient::finishLoadingADSource()");
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void failToLoadADSource(string placementId,string callbackJson, string code, string error)
{
Debug.Log("Unity: ATNativeAdClient::failToLoadADSource()");
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId,code,error));
}
public void startBiddingADSource(string placementId, string callbackJson)
{
Debug.Log("Unity: ATNativeAdClient::startBiddingADSource()");
onAdSourceBiddingAttemptEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void finishBiddingADSource(string placementId, string callbackJson)
{
Debug.Log("Unity: ATNativeAdClient::finishBiddingADSource()");
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void failBiddingADSource(string placementId,string callbackJson, string code, string error)
{
Debug.Log("Unity: ATNativeAdClient::failBiddingADSource()");
onAdSourceBiddingFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId,callbackJson,code,error));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3c3f95e41f96d41ff9911a95ecbbabbb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,98 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnyThinkAds.Common;
using AnyThinkAds.Api;
#pragma warning disable 0067
namespace AnyThinkAds.iOS
{
public class ATNativeBannerAdClient : IATNativeBannerAdClient
{
public event EventHandler<ATAdEventArgs> onAdLoadEvent;
public event EventHandler<ATAdErrorEventArgs> onAdLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdImpressEvent;
public event EventHandler<ATAdEventArgs> onAdClickEvent;
public event EventHandler<ATAdEventArgs> onAdVideoStartEvent;
public event EventHandler<ATAdEventArgs> onAdVideoEndEvent;
public event EventHandler<ATAdProgressEventArgs> onAdVideoProgressEvent;
public event EventHandler<ATAdEventArgs> onAdCloseEvent;
public event EventHandler<ATAdEventArgs> onAdSourceAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceLoadFailureEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingAttemptEvent;
public event EventHandler<ATAdEventArgs> onAdSourceBiddingFilledEvent;
public event EventHandler<ATAdErrorEventArgs> onAdSourceBiddingFailureEvent;
private ATNativeBannerAdListener listener;
public void loadAd(string placementId, string mapJson) {
Debug.Log("ATNativeBannerAdClient::loadAd()");
ATNativeBannerAdWrapper.setClientForPlacementID(placementId, this);
Debug.Log("ATNativeBannerAdClient::loadAd(), after set client");
ATNativeBannerAdWrapper.loadAd(placementId, mapJson);
Debug.Log("ATNativeBannerAdClient::loadAd(), after invoke load ad");
}
public bool adReady(string placementId) {
Debug.Log("ATNativeBannerAdClient::adReady()");
return ATNativeBannerAdWrapper.adReady(placementId);
}
public void setListener(ATNativeBannerAdListener listener) {
Debug.Log("ATNativeBannerAdClient::setListener()");
this.listener = listener;
}
public void showAd(string placementId, ATRect rect, Dictionary<string, string> pairs) {
Debug.Log("ATNativeBannerAdClient::showAd()");
ATNativeBannerAdWrapper.showAd(placementId, rect, pairs);
}
public void removeAd(string placementId) {
Debug.Log("ATNativeBannerAdClient::removeAd()");
ATNativeBannerAdWrapper.removeAd(placementId);
}
//Listener method(s)
public void onAdLoaded(string placementId) {
Debug.Log("ATNativeBannerAdClient::onAdLoaded()");
onAdLoadEvent?.Invoke(this, new ATAdEventArgs(placementId));
}
public void onAdLoadFail(string placementId, string code, string message) {
Debug.Log("ATNativeBannerAdClient::onAdLoadFail()");
onAdLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, "", code, message));
}
public void onAdImpressed(string placementId, string callbackJson) {
Debug.Log("ATNativeBannerAdClient::onAdImpressed()");
onAdImpressEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void onAdClicked(string placementId, string callbackJson) {
Debug.Log("ATNativeBannerAdClient::onAdClicked()");
onAdClickEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void onAdAutoRefresh(string placementId, string callbackJson) {
Debug.Log("ATNativeBannerAdClient::onAdAutoRefresh()");
onAdSourceFilledEvent?.Invoke(this, new ATAdEventArgs(placementId,callbackJson));
}
public void onAdAutoRefreshFailure(string placementId, string code, string message) {
Debug.Log("ATNativeBannerAdClient::onAdAutoRefreshFailure()");
onAdSourceLoadFailureEvent?.Invoke(this, new ATAdErrorEventArgs(placementId, "", code, message));
}
public void onAdCloseButtonClicked(string placementId) {
Debug.Log("ATNativeBannerAdClient::onAdCloseButtonClicked()");
onAdCloseEvent?.Invoke(this, new ATAdEventArgs(placementId));
}
}
}

Some files were not shown because too many files have changed in this diff Show More