diff --git a/Assets/Editor/BuildWindow.cs b/Assets/Editor/BuildWindow.cs index c04355862d..b9c670e04a 100644 --- a/Assets/Editor/BuildWindow.cs +++ b/Assets/Editor/BuildWindow.cs @@ -22,8 +22,8 @@ using System.Runtime.InteropServices; namespace TiltBrush { - public class BuildWindow : EditorWindow { - + public class BuildWindow : EditorWindow + { private class HeaderedHorizontalLayout : GUI.Scope { public HeaderedHorizontalLayout(string header, params GUILayoutOption[] options) { GUILayout.BeginVertical(new GUIContent(header), EditorStyles.helpBox, options); @@ -188,6 +188,7 @@ private string SpinnerString() { private int? m_buildLogPosition; private System.IntPtr m_hwnd; private DateTime m_buildCompleteTime; + private static string m_adbPath; private bool AndroidConnected { get { @@ -417,6 +418,11 @@ private void DeviceGui() { private void BuildActionsGui() { using (var builds = new HeaderedVerticalLayout("Build")) { EditorGUILayout.LabelField("Build Path", m_currentBuildPath); + if (!String.IsNullOrEmpty(m_adbPath)) { + EditorGUILayout.LabelField("Adb Path", m_adbPath); + if (!File.Exists(m_adbPath)) + EditorGUILayout.LabelField("Adb status", "ADB not found in expected path."); + } if (m_currentBuildTime.HasValue) { TimeSpan age = DateTime.Now - m_currentBuildTime.Value; EditorGUILayout.LabelField("Creation Time", m_currentBuildTime.Value.ToString()); @@ -463,7 +469,21 @@ private void ScanAndroidDevices() { } } - private void OnBuildSettingsChanged() { + private void OnBuildSettingsChanged() + { + // Only set this if supporting SDK that needs Android (and is installed!). +#if OCULUS_SUPPORTED +#if UNITY_EDITOR_WIN + string adbExe = "adb.exe"; +#else + string adbExe = "adb"; +#endif + // If we're on Android cache the path to adb as it used during building. Need to do it pre-work so on main thread. + m_adbPath = BuildTiltBrush.GuiSelectedBuildTarget == BuildTarget.Android + ? Path.Combine(UnityEditor.Android.AndroidExternalToolsSettings.sdkRootPath, "platform-tools", adbExe) + : null; +#endif + m_currentBuildPath = BuildTiltBrush.GetAppPathForGuiBuild(); if (File.Exists(m_currentBuildPath)) { m_currentBuildTime = File.GetLastWriteTime(m_currentBuildPath); @@ -524,13 +544,8 @@ private void OnBuildSettingsChanged() { public static string[] RunAdb(params string[] arguments) { var process = new System.Diagnostics.Process(); -#if UNITY_EDITOR_WIN - process.StartInfo = - new System.Diagnostics.ProcessStartInfo("adb.exe", String.Join(" ", arguments)); -#else process.StartInfo = - new System.Diagnostics.ProcessStartInfo("adb", String.Join(" ", arguments)); -#endif + new System.Diagnostics.ProcessStartInfo(m_adbPath, String.Join(" ", arguments)); process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.StartInfo.RedirectStandardOutput = true; @@ -541,7 +556,6 @@ public static string[] RunAdb(params string[] arguments) { Concat(process.StandardError.ReadToEnd().Split('\n')).ToArray(); } - private void Update() { if (BuildTiltBrush.GuiSelectedBuildTarget == BuildTarget.Android) { ScanAndroidDevices();