private void setupPortForwarding(int port)
{
#if !UNITY_WEBPLAYER
string adbCommand = string.Format("adb forward tcp:{0} tcp:{0}", port);
System.Diagnostics.Process myProcess;
#if UNITY_EDITOR_WIN
string cmd = @"/k " + adbCommand + " & exit";
Debug.Log ("Executing: [" + cmd + "]");
myProcess = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo myProcessStartInfo =
new System.Diagnostics.ProcessStartInfo("CMD.exe", cmd);
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcessStartInfo.CreateNoWindow = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
#else
Debug.LogFormat("Trying to launch adb: {0}", adbCommand);
myProcess = System.Diagnostics.Process.Start("bash", string.Format("-l -c \"{0}\"",
adbCommand));
#endif
myProcess.WaitForExit();
int exitCode = myProcess.ExitCode;
myProcess.Close();
if (exitCode == 0) {
Debug.LogFormat("adb process succeeded (exit code 0).");
} else {
Debug.LogErrorFormat("adb process FAILED (exit code {0}). Check that the Android SDK " +
"is installed and that the adb command is in your PATH environment variable.",
exitCode);
}
#endif
}