Skip to content

Instantly share code, notes, and snippets.

@kuriharaan
Last active December 5, 2015 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuriharaan/31f06c5d9db0204df893 to your computer and use it in GitHub Desktop.
Save kuriharaan/31f06c5d9db0204df893 to your computer and use it in GitHub Desktop.
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