update 1.1.25

This commit is contained in:
2024-03-12 02:17:14 +08:00
parent 93501423d7
commit d0a6ab116e
346 changed files with 1902 additions and 4759 deletions

View File

@@ -8,6 +8,10 @@ using System.Xml.Linq;
using UnityEditor;
using UnityEditor.Android;
using System.Text.RegularExpressions;
using System.Diagnostics;
using UnityEngine;
using System.Text;
namespace AnyThink.Scripts.Editor
{
@@ -35,7 +39,9 @@ namespace AnyThink.Scripts.Editor
// replaceAppBuildPluginVersion(path);
#endif
// replaceAppBuildPluginVersion(path);
// handleNetworksConfit(path);
handleNetworksConfit(path);
// handleNetworkResMerge(path);
// callGradleTask(path);
}
//修改项目的根目录下的build.gradle文件的插件版本号
private static void replaceBuildPluginVersion(string buildGradlePath)
@@ -242,10 +248,10 @@ namespace AnyThink.Scripts.Editor
{
lines.Insert(androidStartIndex + 1, " packagingOptions {\n merge 'META-INF/com.android.tools/proguard/coroutines.pro'\n exclude 'META-INF/*.kotlin_module'\n }");
}
if (!isConfigAll)
{
lines.Insert(androidStartIndex -1, "configurations.all {\n resolutionStrategy {\n force 'androidx.core:core:1.6.0'\n force 'androidx.recyclerview:recyclerview:1.1.0' \n }\n}");
}
// if (!isConfigAll)
// {
// lines.Insert(androidStartIndex -1, "configurations.all {\n resolutionStrategy {\n force 'androidx.core:core:1.6.0'\n force 'androidx.recyclerview:recyclerview:1.1.0' \n }\n}");
// }
}
// configurations.all {
// resolutionStrategy {
@@ -265,6 +271,84 @@ namespace AnyThink.Scripts.Editor
}
}
}
private static void handleNetworkResMerge(string path) {
ATLog.log("handleNetworkResMerge() >>> path: " + path);
#if UNITY_2019_3_OR_NEWER
var buildGradlePath = Path.Combine(path, "../launcher/build.gradle");
#else
var buildGradlePath = Path.Combine(path, "launcher/build.gradle");
#endif
List<string> lines = new List<string>();
bool isAdded = false;
using (StreamReader reader = new StreamReader(buildGradlePath))
{
string line;
while ((line = reader.ReadLine()) != null)
{
if (line.Contains("task handleNetworkResMerge")) {
isAdded = true;
}
lines.Add(line);
}
}
if (isAdded) {
return;
}
using (StreamReader reader = new StreamReader("Assets/AnyThinkPlugin/Script/Editor/network_res_handle.gradle"))
{
string line;
while ((line = reader.ReadLine()) != null)
{
lines.Add(line);
}
}
using (StreamWriter writer = new StreamWriter(buildGradlePath))
{
foreach (string line in lines)
{
writer.WriteLine(line);
}
}
}
private static void callGradleTask(string path) {
// 设置你想要启动的Gradle任务
string gradleTask = "handleNetworkResMerge"; // 例如: assembleDebug or assembleRelease
// 开始一个新的进程来执行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命令
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项目路径
ATLog.log("callGradleTask() >>> path: " + path);
using (var process = Process.Start(psi))
{
// 读取输出信息
while (!process.StandardOutput.EndOfStream)
{
var line = process.StandardOutput.ReadLine();
UnityEngine.Debug.Log(line);
}
// 读取错误信息
while (!process.StandardError.EndOfStream)
{
var line = process.StandardError.ReadLine();
UnityEngine.Debug.LogError(line);
}
}
}
}
}
#endif