in Assets/MixedRealityToolkit/Utilities/BuildAndDeploy/BuildDeployWindow.cs [644:924]
private void DeployGUI()
{
Debug.Assert(portalConnections.Connections.Count != 0);
Debug.Assert(currentConnectionInfoIndex >= 0);
if (currentConnectionInfoIndex > portalConnections.Connections.Count - 1)
{
currentConnectionInfoIndex = 0;
}
GUILayout.BeginVertical();
EditorGUI.BeginChangeCheck();
GUILayout.BeginHorizontal();
GUI.enabled = IsHoloLensConnectedUsb;
if (GUILayout.Button(pairHoloLensUsbLabel, GUILayout.Width(128f)))
{
EditorApplication.delayCall += PairDevice;
}
GUI.enabled = true;
GUILayout.FlexibleSpace();
var previousLabelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 64;
bool useSSL = EditorGUILayout.Toggle(useSSLLabel, UwpBuildDeployPreferences.UseSSL);
EditorGUIUtility.labelWidth = previousLabelWidth;
currentConnectionInfoIndex = EditorGUILayout.Popup(currentConnectionInfoIndex, targetIps);
var currentConnection = portalConnections.Connections[currentConnectionInfoIndex];
bool currentConnectionIsLocal = IsLocalConnection(currentConnection);
if (currentConnectionIsLocal)
{
currentConnection.MachineName = LOCAL_MACHINE;
}
GUI.enabled = IsValidIpAddress(currentConnection.IP);
if (GUILayout.Button(addConnectionLabel, GUILayout.Width(20)))
{
portalConnections.Connections.Add(new DeviceInfo(EMPTY_IP_ADDRESS, currentConnection.User, currentConnection.Password));
currentConnectionInfoIndex++;
currentConnection = portalConnections.Connections[currentConnectionInfoIndex];
UpdatePortalConnections();
}
GUI.enabled = portalConnections.Connections.Count > 1 && currentConnectionInfoIndex != 0;
if (GUILayout.Button(removeConnectionLabel, GUILayout.Width(20)))
{
portalConnections.Connections.RemoveAt(currentConnectionInfoIndex);
currentConnectionInfoIndex--;
currentConnection = portalConnections.Connections[currentConnectionInfoIndex];
UpdatePortalConnections();
}
GUI.enabled = true;
GUILayout.EndHorizontal();
GUILayout.Space(5);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.Label(currentConnection.MachineName, GUILayout.Width(HALF_WIDTH));
GUILayout.EndHorizontal();
previousLabelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 64;
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.enabled = !currentConnectionIsLocal;
currentConnection.IP = EditorGUILayout.TextField(ipAddressLabel, currentConnection.IP, GUILayout.Width(HALF_WIDTH));
GUI.enabled = true;
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
currentConnection.User = EditorGUILayout.TextField("Username", currentConnection.User, GUILayout.Width(HALF_WIDTH));
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
currentConnection.Password = EditorGUILayout.PasswordField("Password", currentConnection.Password, GUILayout.Width(HALF_WIDTH));
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
EditorGUIUtility.labelWidth = 152;
bool processAll = EditorGUILayout.Toggle(doAllLabel, UwpBuildDeployPreferences.TargetAllConnections, GUILayout.Width(176));
EditorGUIUtility.labelWidth = 86;
bool fullReinstall = EditorGUILayout.Toggle(uninstallLabel, UwpBuildDeployPreferences.FullReinstall, GUILayout.ExpandWidth(false));
EditorGUIUtility.labelWidth = previousLabelWidth;
if (EditorGUI.EndChangeCheck())
{
UwpBuildDeployPreferences.TargetAllConnections = processAll;
UwpBuildDeployPreferences.FullReinstall = fullReinstall;
UwpBuildDeployPreferences.UseSSL = useSSL;
Rest.UseSSL = useSSL;
// Format our local connection
if (currentConnection.IP.Contains(LOCAL_IP_ADDRESS))
{
currentConnection.IP = LOCAL_MACHINE;
}
portalConnections.Connections[currentConnectionInfoIndex] = currentConnection;
UpdatePortalConnections();
Repaint();
}
GUILayout.FlexibleSpace();
// Connect
if (!IsLocalConnection(currentConnection))
{
GUI.enabled = IsValidIpAddress(currentConnection.IP) && IsCredentialsValid(currentConnection);
if (GUILayout.Button("Connect"))
{
EditorApplication.delayCall += () =>
{
ConnectToDevice(currentConnection);
};
}
GUI.enabled = true;
}
GUI.enabled = DevicePortalConnectionEnabled && CanInstall;
// Open web portal
if (GUILayout.Button("Open Device Portal", GUILayout.Width(128f)))
{
EditorApplication.delayCall += () => OpenDevicePortal(portalConnections, currentConnection);
}
GUI.enabled = true;
GUILayout.EndHorizontal();
// Build list
if (Builds.Count == 0)
{
GUILayout.Label("*** No builds found in build directory", EditorStyles.boldLabel);
}
else
{
EditorGUILayout.Separator();
GUILayout.BeginVertical(GUILayout.ExpandHeight(true));
scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
foreach (var fullBuildLocation in Builds)
{
int lastBackslashIndex = fullBuildLocation.LastIndexOf("\\", StringComparison.Ordinal);
var directoryDate = Directory.GetLastWriteTime(fullBuildLocation).ToString("yyyy/MM/dd HH:mm:ss");
string packageName = fullBuildLocation.Substring(lastBackslashIndex + 1);
GUILayout.Space(2);
EditorGUILayout.BeginHorizontal();
GUILayout.Space(12);
GUI.enabled = CanInstall;
if (GUILayout.Button("Install", GUILayout.Width(96)))
{
EditorApplication.delayCall += () =>
{
if (processAll)
{
InstallAppOnDevicesList(fullBuildLocation, portalConnections);
}
else
{
InstallOnTargetDevice(fullBuildLocation, currentConnection);
}
};
}
GUI.enabled = true;
// Uninstall...
GUI.enabled = CanInstall;
if (GUILayout.Button("Uninstall", GUILayout.Width(96)))
{
EditorApplication.delayCall += () =>
{
if (processAll)
{
UninstallAppOnDevicesList(portalConnections);
}
else
{
UninstallAppOnTargetDevice(currentConnection);
}
};
}
GUI.enabled = true;
bool canLaunchLocal = currentConnectionInfoIndex == 0 && IsHoloLensConnectedUsb;
bool canLaunchRemote = DevicePortalConnectionEnabled && CanInstall && currentConnectionInfoIndex != 0;
// Launch app...
GUI.enabled = canLaunchLocal || canLaunchRemote;
if (GUILayout.Button(new GUIContent(isAppRunning ? "Kill App" : "Launch App", "These are remote commands only"), GUILayout.Width(96)))
{
EditorApplication.delayCall += () =>
{
if (isAppRunning)
{
if (processAll)
{
KillAppOnDeviceList(portalConnections);
isAppRunning = false;
}
else
{
KillAppOnTargetDevice(currentConnection);
}
}
else
{
if (processAll)
{
LaunchAppOnDeviceList(portalConnections);
isAppRunning = true;
}
else
{
LaunchAppOnTargetDevice(currentConnection);
}
}
};
}
GUI.enabled = true;
// Log file
string localLogPath = $"%USERPROFILE%\\AppData\\Local\\Packages\\{PlayerSettings.productName}\\TempState\\UnityPlayer.log";
bool localLogExists = File.Exists(localLogPath);
GUI.enabled = localLogExists || canLaunchRemote || canLaunchLocal;
if (GUILayout.Button("View Log", GUILayout.Width(96)))
{
EditorApplication.delayCall += () =>
{
if (processAll)
{
OpenLogFilesOnDeviceList(portalConnections, localLogPath);
}
else
{
OpenLogFileForTargetDevice(currentConnection, localLogPath);
}
};
}
GUI.enabled = true;
GUILayout.Space(8);
GUILayout.Label(new GUIContent($"{packageName} ({directoryDate})"));
EditorGUILayout.EndHorizontal();
}
GUILayout.EndScrollView();
GUILayout.EndVertical();
}
GUILayout.EndVertical();
}