You've already forked Commercialization.topon
更新sdk
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user