Untitled
unknown
plain_text
5 years ago
2.0 kB
7
Indexable
[MenuItem("EditorUtils/" + "BUILD APK")]
private static void BuildAPK()
{
string path = PreBuildSetup();
BuildPipeline.BuildPlayer(GetScenePaths(), path, BuildTarget.Android, BuildOptions.None);
ShowExplorer(path);
}
[MenuItem("EditorUtils/" + "BUILD AND RUN APK")]
private static void BuildAndRunAPK()
{
string path = PreBuildSetup();
// Build player.
BuildPipeline.BuildPlayer(GetScenePaths(), path, BuildTarget.Android, BuildOptions.AutoRunPlayer);
ShowExplorer(path);
}
static string PreBuildSetup()
{
string keyStorePassPath = Path.GetFullPath(
"Assets/../../Key/ReleaseKey/keystore.txt");
string keyStorePath = Path.GetFullPath(
"Assets/../../Key/ReleaseKey/idle-zombie-release.keystore");
string pass = File.ReadAllText(keyStorePassPath);
PlayerSettings.Android.keystoreName = keyStorePath;
PlayerSettings.Android.keystorePass = pass;
PlayerSettings.Android.keyaliasName = "pine-entertainment";
PlayerSettings.Android.keyaliasPass = pass;
// EditorWindow.GetWindow(Type.GetType("UnityEditor.BuildPlayerWindow,UnityEditor"));
string name = $"IdleZombie_v{Application.version}";
string path = EditorUtility.SaveFilePanel("Choose Location of Built Game", "", name, "apk");
return path;
}
static string[] GetScenePaths()
{
string[] scenes = new string[EditorBuildSettings.scenes.Length];
for (int i = 0; i < scenes.Length; i++)
{
scenes[i] = EditorBuildSettings.scenes[i].path;
}
return scenes;
}
static void ShowExplorer(string itemPath)
{
itemPath = itemPath.Replace(@"/", @"\"); // explorer doesn't like front slashes
System.Diagnostics.Process.Start("explorer.exe", "/select," + itemPath);
}Editor is loading...