Last active
July 29, 2019 09:29
-
-
Save TsubameUnity/7cd313c780c712973d1e43a4aca39314 to your computer and use it in GitHub Desktop.
64bit対応AAB書き出し後apkインストール用(BundleToolPathは https://github.com/google/bundletool/releasesよりjarをDLして配置)
This file contains hidden or 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
public class AABBuildAndInstall{ | |
[MenuItem("ビルド/AAB BuildInstall #&b")] | |
static void BuildInstallAAB() | |
{ | |
var path = System.Environment.CurrentDirectory; | |
var fullPath = Path.Combine(path, AABName); | |
var levels = EditorBuildSettings.scenes.Where(x => x.enabled).Select(x => x.path).ToArray(); | |
PlayerSettings.SetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup, ScriptingImplementation.IL2CPP); | |
PlayerSettings.Android.targetArchitectures = AndroidArchitecture.All; | |
PlayerSettings.Android.keystoreName = Path.Combine(path, "user.keystore"); | |
PlayerSettings.Android.keystorePass = KeyPass; | |
PlayerSettings.Android.keyaliasName = KeyPass; | |
PlayerSettings.Android.keyaliasPass = KeyPass; | |
EditorUserBuildSettings.buildAppBundle = true; | |
BuildPipeline.BuildPlayer(levels, fullPath, BuildTarget.Android, BuildOptions.CompressWithLz4); | |
InstallAAB(); | |
} | |
[MenuItem("ビルド/AAB Install #&i")] | |
static void InstallAAB() | |
{ | |
var path = System.Environment.CurrentDirectory; | |
var fullPath = Path.Combine(path, AABName); | |
var proc = new Process(); | |
proc.StartInfo.FileName = System.Environment.GetEnvironmentVariable("ComSpec"); | |
proc.StartInfo.Arguments = $@"/k java -Xmx1024m -Xms1024m -jar {BundleToolPath} build-apks --bundle={fullPath} --overwrite --connected-device --output={Path.Combine(path, APKsName)} --ks={PlayerSettings.Android.keystoreName} --ks-key-alias={PlayerSettings.Android.keyaliasName} --ks-pass=pass:{PlayerSettings.Android.keyaliasPass} & java -jar {BundleToolPath} install-apks --adb={ADBPath} --apks={Path.Combine(path, APKsName)} & adb shell am start -n {PlayerSettings.GetApplicationIdentifier(EditorUserBuildSettings.selectedBuildTargetGroup)}/com.unity3d.player.UnityPlayerActivity & exit"; | |
proc.StartInfo.CreateNoWindow = true; | |
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; | |
proc.Start(); | |
proc.WaitForExit(); | |
EditorUtility.DisplayDialog("ビルド", "インストール完了", "OK"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment