private static void LaunchMobileClient() { try { // Find ADB tool var sdkRootPath = EditorPrefs.GetString("AndroidSdkRoot"); if (string.IsNullOrEmpty(sdkRootPath)) { Debug.LogError($"Could not find Android SDK. Please set the SDK location in your editor preferences."); return; } var adbPath = Path.Combine(sdkRootPath, "platform-tools", "adb"); EditorUtility.DisplayProgressBar("Launching Mobile Client", "Installing APK", 0.3f); // Find apk to install if (!TryGetApkPath(AbsoluteApkPath, out var apkPath)) { Debug.LogError($"Could not find a built out Android binary in \"{AbsoluteApkPath}\" to launch."); return; } // Ensure an android device/emulator is present if (RedirectedProcess.Run(adbPath, "get-state") != 0) { Debug.LogError("No Android device/emulator detected."); return; } // Install apk on connected phone / emulator RedirectedProcess.Run(adbPath, "install", "-r", apkPath); EditorUtility.DisplayProgressBar("Launching Mobile Client", "Launching Client", 0.9f); // Optional arguments to be passed, same as standalone // Use this to pass through the local ip to connect to var runtimeIp = GdkToolsConfiguration.GetOrCreateInstance().RuntimeIp; var arguments = new StringBuilder(); if (!string.IsNullOrEmpty(runtimeIp)) { arguments.Append($"+{RuntimeConfigNames.ReceptionistHost} {runtimeIp}"); } // Get chosen android package id and launch var bundleId = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.Android); RedirectedProcess.Run(adbPath, "shell", "am", "start", "-S", "-n", $"{bundleId}/com.unity3d.player.UnityPlayerActivity", "-e", "\"arguments\"", $"\\\"{arguments.ToString()}\\\""); EditorUtility.DisplayProgressBar("Launching Mobile Client", "Done", 1.0f); } finally { EditorUtility.ClearProgressBar(); } }
private static void Zip(string zipAbsolutePath, string basePath, bool useCompression) { using (new ShowProgressBarScope($"Package {basePath}")) { RedirectedProcess.Run(Common.SpatialBinary, "file", "zip", $"--output=\"{Path.GetFullPath(zipAbsolutePath)}\"", $"--basePath=\"{Path.GetFullPath(basePath)}\"", "\"**\"", $"--compression={useCompression}"); } }