Last active
December 5, 2015 15:12
-
-
Save kuriharaan/31f06c5d9db0204df893 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using System.Collections; | |
using System.Diagnostics; | |
public class InstallAndRun : EditorWindow | |
{ | |
[MenuItem("Android/Install and Run")] | |
public static void DoInstallAndRun() | |
{ | |
string adbPath = "[AndroidSdkPath]\\platform-tools\\adb.exe"; // AndroidSdkPathは環境に合わせて変更 | |
string apkPath = EditorUtility.OpenFilePanel("Select apk file", "", "apk"); //apkファイルの選択ダイアログを開く | |
if( string.IsNullOrEmpty(apkPath) ) | |
{ | |
return; | |
} | |
//インストールプロセスを実行: adb install -r apk | |
Process installProcess = new Process(); | |
installProcess.StartInfo.FileName = adbPath; | |
installProcess.StartInfo.Arguments = "install -r " + apkPath; | |
installProcess.Start(); | |
installProcess.WaitForExit(); | |
// 起動プロセスを実行: adb shell am start -n YourActivity | |
Process runProcess = new Process(); | |
runProcess.StartInfo.FileName = adbPath; | |
runProcess.StartInfo.Arguments = "shell am start -n " + Application.bundleIdentifier + "/com.unity3d.player.UnityPlayerActivity"; | |
runProcess.Start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment