更新sdk

This commit is contained in:
2026-03-18 15:52:02 +08:00
parent e3781c731d
commit 8d4617f851
120 changed files with 972 additions and 375 deletions

View File

@@ -231,8 +231,8 @@ namespace AnyThink.Scripts.Editor
{
Directory.CreateDirectory(resXmlPath);
}
// var fromScriptableObject = MonoScript.FromScriptableObject(this);
var xmlPath = GetScriptsPath("ATPostProcessBuildAndroid");
var xmlPath = GetScriptsPath("ATPostProcessBuildAndroid");
saveFile($"{xmlPath}/anythink_network_security_config.xml", resXmlPath);
}
@@ -243,17 +243,15 @@ namespace AnyThink.Scripts.Editor
file.CopyTo(toFilesPath + "/" + newFileName, true);
}
public static string GetScriptsPath (string scriptName)
public static string GetScriptsPath(string scriptName)
{
string[] path = UnityEditor.AssetDatabase.FindAssets(scriptName);
if(path.Length>1)
var guids = AssetDatabase.FindAssets($"{scriptName} t:Script");
if (guids.Length != 1)
{
// Debug.LogError("有同名文件"+_scriptName+"获取路径失败");
return null;
}
//将字符串中得脚本名字和后缀统统去除掉
string _path = AssetDatabase.GUIDToAssetPath(path[0]).Replace((@"/" +scriptName +".cs"),"");
return _path;
return AssetDatabase.GUIDToAssetPath(guids[0]).Replace("/" + scriptName + ".cs", "");
}
private static void addNetworkSecurityConfigInApplication(string path, bool isChina)
@@ -341,4 +339,4 @@ namespace AnyThink.Scripts.Editor
}
#endif
#endif

View File

@@ -104,6 +104,7 @@ namespace AnyThink.Scripts.Editor
bunldePathsToAdd.Add(Path.Combine("Pods/", "BigoADS/BigoADS/BigoADSRes.bundle"));
bunldePathsToAdd.Add(Path.Combine("Pods/", "Ads-Global/SDK/PAGAdSDK.bundle"));
bunldePathsToAdd.Add(Path.Combine("Pods/", "Ads-CN/SDK/CSJAdSDK.bundle"));
bunldePathsToAdd.Add(Path.Combine("Pods/", "Ads-CN-Beta/SDK/CSJAdSDK.bundle"));
return bunldePathsToAdd;
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 88e0e347ecf5f4877b7026a0b60b5df0
guid: 2e2b9e45df1464e4ca34d6674718bb2a
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -279,6 +279,11 @@ namespace AnyThink.Scripts.Editor
#else
var buildGradlePath = Path.Combine(path, "launcher/build.gradle");
#endif
if (!File.Exists(buildGradlePath))
{
return;
}
List<string> lines = new List<string>();
bool isAdded = false;
@@ -296,7 +301,22 @@ namespace AnyThink.Scripts.Editor
if (isAdded) {
return;
}
using (StreamReader reader = new StreamReader("Assets/AnyThinkPlugin/Script/Editor/network_res_handle.gradle"))
var scriptDirectory = GetScriptsPath("ATProcessBuildGradleAndroid");
if (string.IsNullOrEmpty(scriptDirectory))
{
ATLog.log("handleNetworkResMerge() >>> script directory not found.");
return;
}
var networkResHandleGradlePath = Path.Combine(scriptDirectory, "network_res_handle.gradle");
if (!File.Exists(networkResHandleGradlePath))
{
ATLog.log("handleNetworkResMerge() >>> gradle template missing: " + networkResHandleGradlePath);
return;
}
using (StreamReader reader = new StreamReader(networkResHandleGradlePath))
{
string line;
while ((line = reader.ReadLine()) != null)
@@ -317,19 +337,34 @@ namespace AnyThink.Scripts.Editor
// 设置你想要启动的Gradle任务
string gradleTask = "handleNetworkResMerge"; // 例如: assembleDebug or assembleRelease
var gradleProjectRootPath = GetGradleProjectRootPath(path);
if (!Directory.Exists(gradleProjectRootPath))
{
ATLog.log("callGradleTask() >>> gradle root not found: " + gradleProjectRootPath);
return;
}
var wrapperFileName = Application.platform == RuntimePlatform.WindowsEditor ? "gradlew.bat" : "gradlew";
var gradleWrapperPath = Path.Combine(gradleProjectRootPath, wrapperFileName);
if (!File.Exists(gradleWrapperPath))
{
ATLog.log("callGradleTask() >>> gradle wrapper missing: " + gradleWrapperPath);
return;
}
// 开始一个新的进程来执行Gradle任务
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Application.platform == RuntimePlatform.WindowsEditor ? "cmd" : "bash";
psi.Arguments = Application.platform == RuntimePlatform.WindowsEditor ?
$"/c gradlew {gradleTask}" : // Windows cmd命令
$"-c './gradlew {gradleTask}'"; // UNIX bash命令
$"/c \"{wrapperFileName} {gradleTask}\"" : // Windows cmd命令
$"-c './{wrapperFileName} {gradleTask}'"; // UNIX bash命令
psi.UseShellExecute = false;
psi.StandardOutputEncoding = Encoding.UTF8;
psi.StandardErrorEncoding = Encoding.UTF8;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.CreateNoWindow = true;
psi.WorkingDirectory = "/Users/quinx/Desktop/workspace_topon/sdk_source/a_unity_demo/TestAnyThinkUnityPlugin/Library/Bee/Android/Prj/Mono2x/Gradle"; // 这里应该是你的Android项目路径
psi.WorkingDirectory = gradleProjectRootPath;
ATLog.log("callGradleTask() >>> path: " + path);
@@ -349,6 +384,26 @@ namespace AnyThink.Scripts.Editor
}
}
}
private static string GetGradleProjectRootPath(string path)
{
#if UNITY_2019_3_OR_NEWER
return Path.GetFullPath(Path.Combine(path, ".."));
#else
return Path.GetFullPath(path);
#endif
}
public static string GetScriptsPath(string scriptName)
{
var guids = AssetDatabase.FindAssets($"{scriptName} t:Script");
if (guids.Length != 1)
{
return null;
}
return AssetDatabase.GUIDToAssetPath(guids[0]).Replace("/" + scriptName + ".cs", "");
}
}
}
#endif
#endif