public static void InitAndroidDebug(string apkRelPath) { var sdk = EditorPrefs.GetString("AndroidSdkRoot"); var adb = $"{sdk}/platform-tools/adb"; var lines = Sh($"{adb} devices").Split("\n"); string device = ""; for (int i = 0; i < lines.Length; i++) { var line = lines[i]; var m = line.Match(@"(\d+\.\d+\.\d+\.\d+\:\d+)[\t\s]+device"); if (m.Groups[0].Value != "") { device = m.Groups[1].Value; break; } } if (device != "") { var buildToolsDir = RoFile.Ls($"{sdk}/build-tools").SortBy((path) => { return(path); }).Last(); var aapt = RoFile.Join(buildToolsDir, "aapt"); var apk = RoFile.Join(EditorEnv.pj, apkRelPath); var dumpStr = Sh($"{aapt} dump badging \"{apk}\""); var pkgName = dumpStr.Match(@"package: name='(\S+)'").Groups[1].Value; var mainAct = dumpStr.Match(@"launchable-activity: name='(\S+)'").Groups[1].Value; var forwardPort = UnityEditorInternal.ProfilerDriver.directConnectionPort.ToInt() + 1; // make sure forward port is not equal profile port, profile port will always bind when unity editor start // if (startDebugThr != null) // { // startDebugThr.Abort(); // startDebugThr = null; // } // // startDebugThr = new Thread(() => // { var forwardCmd = $"{adb} -s {device} forward \"tcp:{forwardPort}\" localabstract:Unity-{pkgName}"; Debug.Log($"run - {forwardCmd}"); Sys(forwardCmd); var installCmd = $"{adb} -s {device} install -r \"{apk}\""; Debug.Log($"run - {installCmd}"); Sys(installCmd); var startCmd = $"{adb} -s {device} shell am start -n {pkgName}/{mainAct}"; Debug.Log($"run - {startCmd}"); Sys(startCmd); Notify("Init Debug finish"); // }); // Notify("start install apk and launch android debug server"); // startDebugThr.Start(); } else { throw new SystemException( "cannot find wireless connected real android device, please use real android device and connect it with wireless, for ex, adb connect 192.168.1.102:5555"); } }
private static void St2() { var hasLibCSharpFileMakeCompileSlow = false; foreach (var p in RoFile.Ls(EditorScript.Ro.EditorEnv.assetsPath)) { var isLibDir = RoFile.IsDir(p) && !RoFile.Basename(p) .IsMatch(@"^(Script|PostProcessing|Scripts|Editor|EditorScript|Draft|Test|Plugins|Standard Assets)$"); if (isLibDir) { foreach (var p2 in RoFile.FF(p)) { if (p2.IsMatch("\\.cs$")) { hasLibCSharpFileMakeCompileSlow = true; var rootDir = RoFile.Rel(p2, EditorEnv.assetsPath).Match("[^/]+").ToString(); Shell.NotifyWarn( $"In *Assets/{rootDir}*, it has lib c# file in Assets not *Assets/Standard Assets* to make compile slow, run *mad compile time optimizer* or maunally moving all lib c# files to *Assets/Standard Assets* to improve it"); break; } } } if (hasLibCSharpFileMakeCompileSlow) { break; } } }
private static void St2() { var shouldBeIgnoredInBuildScripts = new List <string>(); foreach (var path in RoFile.Ls(EditorEnv.assetsPath)) { if (RoFile.IsDir(path)) { if (RoFile.Basename(path).IsMatch("(Editor|Script|Standard Assets)")) { continue; } var fs = RoFile.FF(path); fs.Each((path2) => { if (path2.IsMatch("\\.cs$") && !RoFile.Read(path2).IsMatch("#if UNITY_EDITOR")) { shouldBeIgnoredInBuildScripts.Add(path2); } }); } } if (shouldBeIgnoredInBuildScripts.Count > 0) { throw new SystemException( "following code should be marked #if UNITY_EDITOR to only run in unity editor not unity build" + "\n" + shouldBeIgnoredInBuildScripts.Join("\n")); } }