fix:1、删除上一个sdk,更换新的。2、删除了max广告

This commit is contained in:
2026-05-27 09:28:34 +08:00
parent 978797b678
commit 69c818e992
1039 changed files with 99687 additions and 94871 deletions
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 12fbfba3b2ca54344b20630dc7e0b64a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,125 @@
#if UNITY_ANDROID
using System.IO;
using System.Text.RegularExpressions;
using System.Xml;
using UnityEditor;
using UnityEditor.Android;
using UnityEngine;
public class BuildPostProcessorVoSdk : IPostGenerateGradleAndroidProject
{
public int callbackOrder => 0;
public void OnPostGenerateGradleAndroidProject(string path)
{
Debug.Log("AndroidBuildPostProcessor running after gradle project generation");
// 添加AndroidManifest权限
AddManifestPermissions(path);
}
private void AddManifestPermissions(string gradleProjectPath)
{
string manifestPath = Path.Combine(gradleProjectPath, "src/main/AndroidManifest.xml");
if (!File.Exists(manifestPath))
{
Debug.LogError("AndroidManifest.xml not found at: " + manifestPath);
return;
}
XmlDocument doc = new XmlDocument();
doc.Load(manifestPath);
// 更可靠的方式查找 manifest 节点
XmlNode manifestNode = doc.SelectSingleNode("//manifest");
if (manifestNode == null)
{
Debug.LogError("No manifest node found in AndroidManifest.xml");
Debug.Log("Trying to parse document element as manifest...");
manifestNode = doc.DocumentElement;
if (manifestNode == null || manifestNode.Name != "manifest")
{
Debug.LogError("Failed to find manifest node, document element is: " +
(manifestNode?.Name ?? "null"));
return;
}
}
// 要添加的权限列表
string[] permissions = new string[]
{
"android.permission.INTERNET",
"android.permission.ACCESS_NETWORK_STATE",
"android.permission.ACCESS_WIFI_STATE",
"android.permission.WAKE_LOCK",
//"android.permission.WRITE_EXTERNAL_STORAGE",
//"android.permission.READ_PHONE_STATE",
};
// 添加权限
foreach (var permission in permissions)
{
if (!PermissionExists(doc, permission))
{
XmlElement element = doc.CreateElement("uses-permission");
element.SetAttribute("name", "http://schemas.android.com/apk/res/android", permission);
manifestNode.AppendChild(element);
Debug.Log("Added permission: " + permission);
}
}
// 添加queries
AddQueriesIfNeeded(doc, manifestNode);
// 保存修改
doc.Save(manifestPath);
Debug.Log("Successfully updated AndroidManifest.xml");
}
private bool PermissionExists(XmlDocument doc, string permissionName)
{
XmlNodeList nodes = doc.GetElementsByTagName("uses-permission");
foreach (XmlNode node in nodes)
{
var nameAttr = node.Attributes?["android:name"];
if (nameAttr != null && nameAttr.Value == permissionName)
return true;
}
return false;
}
private void AddQueriesIfNeeded(XmlDocument doc, XmlNode manifestNode)
{
// 检查是否已存在queries节点
XmlNode queriesNode = doc.SelectSingleNode("//queries");
if (queriesNode != null) return;
// 创建queries节点
queriesNode = doc.CreateElement("queries");
// 添加package节点
string[] packages = { "com.android.vending", "com.google.android.gms" };
foreach (var package in packages)
{
XmlElement packageElement = doc.CreateElement("package");
packageElement.SetAttribute("name", "http://schemas.android.com/apk/res/android", package);
queriesNode.AppendChild(packageElement);
}
// 将queries节点添加到manifest中(application节点之前)
XmlNode applicationNode = doc.SelectSingleNode("//application");
if (applicationNode != null)
{
manifestNode.InsertBefore(queriesNode, applicationNode);
}
else
{
manifestNode.AppendChild(queriesNode);
}
Debug.Log("Added queries section to AndroidManifest.xml");
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4dd156adc585b2a4a86945dffe211ade
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 17146edb9bfcb1c429cf2b0d1e4fd912
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1d2782da46daec841824043b013b2559
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 631356458fe79814c9113a8a5280c4e4
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 107b406615002e648b7c62bf734eb402
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 861f122a13727394191cff1d1e6606f1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -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:
@@ -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();
}
}
}
@@ -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:
@@ -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();
}
}
}
@@ -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: