fix:1、删除上一个sdk,更换新的。2、删除了max广告
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
// ISDKInitCallback.cs
|
||||
public class ISDKInitCallback : AndroidJavaProxy
|
||||
{
|
||||
public Action<bool, string> onInitResult;
|
||||
|
||||
public ISDKInitCallback() : base("com.rixengine.unity_plugin.ISDKInit") { }
|
||||
|
||||
public void initResult(bool success, string message)
|
||||
{
|
||||
onInitResult?.Invoke(success, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f7e1681c1f6ec44bab6d7dc37a0a3af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
public class VosacoAdSDK
|
||||
{
|
||||
private static AndroidJavaClass _adClass;
|
||||
|
||||
// 初始化SDK
|
||||
public static void Initialize(string host, string token, string sid, string appId, Action<bool, string> callback)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
{
|
||||
LogD("SDK only works on Android platform");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 创建Java回调对象
|
||||
var initCallback = new ISDKInitCallback
|
||||
{
|
||||
onInitResult = callback
|
||||
};
|
||||
|
||||
// 调用Java方法
|
||||
GetAdClass().CallStatic("init", host, token, sid, appId, initCallback);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogE($"Initialize failed: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// 其他接口封装
|
||||
public static void SetDebug(bool enable) => GetAdClass().CallStatic("setDebug", enable);
|
||||
|
||||
public static void SetGDPRConsent(bool consent) => GetAdClass().CallStatic("setSubjectToGDPR", consent);
|
||||
|
||||
public static void SetUserConsent(string consent) => GetAdClass().CallStatic("setUserConsent", consent);
|
||||
|
||||
public static void SetUSPrivacy(string privacy) => GetAdClass().CallStatic("subjectToUSPrivacy", privacy);
|
||||
|
||||
public static void SetExtraParameters(Dictionary<string, object> parameters)
|
||||
{
|
||||
using AndroidJavaObject map = new AndroidJavaObject("java.util.HashMap");
|
||||
foreach (var kv in parameters)
|
||||
{
|
||||
map.Call<AndroidJavaObject>("put", kv.Key, kv.Value);
|
||||
}
|
||||
GetAdClass().CallStatic("setExtraParameters", map);
|
||||
}
|
||||
|
||||
// 获取网络信息
|
||||
public static string GetNetworkName() => GetAdClass().CallStatic<string>("getNetWorkName");
|
||||
public static string GetNetworkVersion() => GetAdClass().CallStatic<string>("getNetWorkVersion");
|
||||
|
||||
public static void LogD(string msg)
|
||||
{
|
||||
GetAdClass().CallStatic("LogD", msg);
|
||||
}
|
||||
|
||||
public static void LogE(string msg)
|
||||
{
|
||||
GetAdClass().CallStatic("LogE", msg);
|
||||
}
|
||||
|
||||
private static AndroidJavaClass GetAdClass()
|
||||
{
|
||||
if (_adClass == null)
|
||||
{
|
||||
_adClass = new AndroidJavaClass("com.rixengine.unity_plugin.RiEngineAd");
|
||||
}
|
||||
return _adClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b157c77988ff5d4a985f156a1a0a43a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
public class VosacoInterAd
|
||||
{
|
||||
private AndroidJavaObject _interAd;
|
||||
private VosacoInterAdListenerProxy _listenerProxy;
|
||||
|
||||
public VosacoInterAd(string unitId)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
// 创建Java插屏广告对象
|
||||
_interAd = new AndroidJavaObject("com.rixengine.unity_plugin.InterAd", unitId);
|
||||
|
||||
// 创建并设置监听器
|
||||
_listenerProxy = new VosacoInterAdListenerProxy();
|
||||
_interAd.Call("SetListener", _listenerProxy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"InterAd creation failed: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// 加载广告
|
||||
public void LoadAd()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
|
||||
try
|
||||
{
|
||||
_interAd.Call("Load");
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"LoadAd failed: {e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 显示广告
|
||||
public void ShowAd()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
try
|
||||
{
|
||||
_interAd.Call("Show");
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"ShowAd failed: {e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 检查广告是否就绪
|
||||
public bool IsAdReady()
|
||||
{
|
||||
if (!IsValid()) return false;
|
||||
|
||||
try
|
||||
{
|
||||
return _interAd.Call<bool>("IsReady");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"IsAdReady error :{e.Message}" );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取广告价格
|
||||
public double GetAdPrice()
|
||||
{
|
||||
if (!IsValid()) return 0;
|
||||
try
|
||||
{
|
||||
return _interAd.Call<double>("GetPrice");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"GetAdPrice error :{e.Message}");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 销毁广告对象
|
||||
public void Destroy()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
|
||||
try
|
||||
{
|
||||
_interAd.Call("Destroy");
|
||||
_interAd?.Dispose();
|
||||
_interAd = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"Destroy error :{e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 注册事件监听器
|
||||
public void AddLoadedListener(Action callback)
|
||||
=> _listenerProxy.OnLoaded += callback;
|
||||
|
||||
public void AddLoadFailedListener(Action callback)
|
||||
=> _listenerProxy.OnLoadFailed += callback;
|
||||
|
||||
public void AddClickedListener(Action callback)
|
||||
=> _listenerProxy.OnClicked += callback;
|
||||
|
||||
public void AddShowListener(Action callback)
|
||||
=> _listenerProxy.OnShow += callback;
|
||||
|
||||
public void AddCloseListener(Action callback)
|
||||
=> _listenerProxy.OnClose += callback;
|
||||
|
||||
public void AddVideoStartListener(Action callback)
|
||||
=> _listenerProxy.OnVideoStart += callback;
|
||||
|
||||
public void AddVideoEndListener(Action callback)
|
||||
=> _listenerProxy.OnVideoEnd += callback;
|
||||
|
||||
public void AddVideoErrorListener(Action callback)
|
||||
=> _listenerProxy.OnVideoError += callback;
|
||||
|
||||
|
||||
private bool IsValid()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
{
|
||||
VosacoAdSDK.LogD("Interstitial ads only supported on Android");
|
||||
return false;
|
||||
}
|
||||
if (_interAd == null)
|
||||
{
|
||||
VosacoAdSDK.LogE("Interstitial ad not initialized");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8830e563eb2340c43be73c58f4f367d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
public class VosacoInterAdListenerProxy : AndroidJavaProxy
|
||||
{
|
||||
|
||||
public event Action OnLoaded;
|
||||
public event Action OnLoadFailed;
|
||||
public event Action OnClicked;
|
||||
public event Action OnShow;
|
||||
public event Action OnClose;
|
||||
public event Action OnVideoStart;
|
||||
public event Action OnVideoEnd;
|
||||
public event Action OnVideoError;
|
||||
|
||||
public VosacoInterAdListenerProxy()
|
||||
: base("com.rixengine.unity_plugin.IInterAdListener") { }
|
||||
|
||||
public void onLoaded()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onLoaded");
|
||||
OnLoaded?.Invoke();
|
||||
}
|
||||
|
||||
public void onLoadFailed()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onLoadFailed");
|
||||
OnLoadFailed?.Invoke();
|
||||
}
|
||||
|
||||
public void onClicked()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onClicked");
|
||||
OnClicked?.Invoke();
|
||||
}
|
||||
|
||||
public void onShow()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onShow");
|
||||
OnShow?.Invoke();
|
||||
}
|
||||
|
||||
public void onClose()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onClose");
|
||||
OnClose?.Invoke();
|
||||
}
|
||||
|
||||
public void onVideoStart()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onVideoStart");
|
||||
OnVideoStart?.Invoke();
|
||||
}
|
||||
|
||||
public void onVideoEnd()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onVideoEnd");
|
||||
OnVideoEnd?.Invoke();
|
||||
}
|
||||
|
||||
public void onVideoError()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onVideoError");
|
||||
OnVideoError?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37493ae495df0a046917718e33d144cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,155 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
public class VosacoRewardAd
|
||||
{
|
||||
private AndroidJavaObject _rewardAd;
|
||||
private VosacoRewardAdListenerProxy _listenerProxy;
|
||||
|
||||
public VosacoRewardAd(string unitId)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
// 创建Java插屏广告对象
|
||||
_rewardAd = new AndroidJavaObject("com.rixengine.unity_plugin.RewardAd", unitId);
|
||||
|
||||
// 创建并设置监听器
|
||||
_listenerProxy = new VosacoRewardAdListenerProxy();
|
||||
_rewardAd.Call("SetListener", _listenerProxy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"RewardAd creation failed: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// 加载广告
|
||||
public void LoadAd()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
|
||||
try
|
||||
{
|
||||
_rewardAd.Call("Load");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"LoadAd failed: {e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 显示广告
|
||||
public void ShowAd()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
try
|
||||
{
|
||||
_rewardAd.Call("Show");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"ShowAd failed: {e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 检查广告是否就绪
|
||||
public bool IsAdReady()
|
||||
{
|
||||
if (!IsValid()) return false;
|
||||
|
||||
try
|
||||
{
|
||||
return _rewardAd.Call<bool>("IsReady");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"IsAdReady error :{e.Message}");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取广告价格
|
||||
public double GetAdPrice()
|
||||
{
|
||||
if (!IsValid()) return 0;
|
||||
try
|
||||
{
|
||||
return _rewardAd.Call<double>("GetPrice");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"GetAdPrice error :{e.Message}");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 销毁广告对象
|
||||
public void Destroy()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
|
||||
try
|
||||
{
|
||||
_rewardAd.Call("Destroy");
|
||||
_rewardAd?.Dispose();
|
||||
_rewardAd = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"Destroy error :{e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 注册事件监听器
|
||||
public void AddLoadedListener(Action callback)
|
||||
=> _listenerProxy.OnLoaded += callback;
|
||||
|
||||
public void AddLoadFailedListener(Action callback)
|
||||
=> _listenerProxy.OnLoadFailed += callback;
|
||||
|
||||
public void AddClickedListener(Action callback)
|
||||
=> _listenerProxy.OnClicked += callback;
|
||||
|
||||
public void AddRewardListener(Action callback)
|
||||
=> _listenerProxy.OnReward += callback;
|
||||
|
||||
public void AddCloseListener(Action callback)
|
||||
=> _listenerProxy.OnClose += callback;
|
||||
|
||||
public void AddVideoStartListener(Action callback)
|
||||
=> _listenerProxy.OnVideoStart += callback;
|
||||
|
||||
public void AddVideoEndListener(Action callback)
|
||||
=> _listenerProxy.OnVideoEnd += callback;
|
||||
|
||||
public void AddVideoErrorListener(Action callback)
|
||||
=> _listenerProxy.OnVideoError += callback;
|
||||
|
||||
|
||||
private bool IsValid()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
{
|
||||
VosacoAdSDK.LogD("Interstitial ads only supported on Android");
|
||||
return false;
|
||||
}
|
||||
if (_rewardAd == null)
|
||||
{
|
||||
VosacoAdSDK.LogE("Interstitial ad not initialized");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40ed3796f8aad0543a2dc4948f2348f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
public class VosacoRewardAdListenerProxy : AndroidJavaProxy
|
||||
{
|
||||
public event Action OnLoaded;
|
||||
public event Action OnLoadFailed;
|
||||
public event Action OnClicked;
|
||||
public event Action OnReward;
|
||||
public event Action OnClose;
|
||||
public event Action OnVideoStart;
|
||||
public event Action OnVideoEnd;
|
||||
public event Action OnVideoError;
|
||||
|
||||
public VosacoRewardAdListenerProxy()
|
||||
: base("com.rixengine.unity_plugin.IRewardListener")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void onLoaded()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onLoaded");
|
||||
OnLoaded?.Invoke();
|
||||
}
|
||||
|
||||
public void onLoadFailed()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onLoadFailed");
|
||||
OnLoadFailed?.Invoke();
|
||||
}
|
||||
|
||||
public void onRewardPlayStart()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onRewardPlayStart");
|
||||
OnVideoStart?.Invoke();
|
||||
}
|
||||
|
||||
public void onRewardPlayEnd()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onRewardPlayEnd");
|
||||
OnVideoEnd?.Invoke();
|
||||
}
|
||||
|
||||
public void onRewardPlayFailed()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onRewardPlayFailed");
|
||||
OnVideoError?.Invoke();
|
||||
}
|
||||
|
||||
public void onRewardClosed()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onRewardClosed");
|
||||
OnClose?.Invoke();
|
||||
}
|
||||
|
||||
public void onRewardClicked()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onRewardClicked");
|
||||
OnClicked?.Invoke();
|
||||
}
|
||||
|
||||
public void onReward()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onReward");
|
||||
OnReward?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d26637076beab3a4aa6cc6a62295c075
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "VosacoSDK",
|
||||
"rootNamespace": "AD.VosacoSDK",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1f8ee83a67449c439100d8ba0f900b3
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user