Skip to content

Commit a9759f6

Browse files
fixed Build Window layout in 2018.2+
1 parent 9d1981f commit a9759f6

File tree

2 files changed

+61
-84
lines changed

2 files changed

+61
-84
lines changed

Assets/MixedRealityToolkit/_Core/Utilities/BuildAndDeploy/BuildDeployWindow.cs renamed to Assets/MixedRealityToolkit/_Core/Utilities/BuildAndDeploy/UwpBuildDeployWindow.cs

Lines changed: 61 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Microsoft.MixedReality.Toolkit.Core.Utilities.Build
2424
/// Build window - supports SLN creation, APPX from SLN, Deploy on device, and misc helper utilities associated with the build/deploy/test iteration loop
2525
/// Requires the device to be set in developer mode and to have secure connections disabled (in the security tab in the device portal)
2626
/// </summary>
27-
public class BuildDeployWindow : EditorWindow
27+
public class UwpBuildDeployWindow : EditorWindow
2828
{
2929
#region Internal Types
3030

@@ -77,7 +77,7 @@ private enum BuildPlatformEnum
7777

7878
private readonly GUIContent buildDirectoryLabel = new GUIContent("Build Directory", "It's recommended to use 'UWP'");
7979

80-
private readonly GUIContent useCSharpProjectsLabel = new GUIContent("Unity C# Projects", "Generate C# Project References for debugging");
80+
private readonly GUIContent useCSharpProjectsLabel = new GUIContent("Generate C# Debug", "Generate C# Project References for debugging.\nOnly availible in .NET Scripting runtime.");
8181

8282
private readonly GUIContent autoIncrementLabel = new GUIContent("Auto Increment", "Increases Version Build Number");
8383

@@ -161,8 +161,7 @@ private static bool IsHoloLensConnectedUsb
161161

162162
#region Fields
163163

164-
private int halfWidth;
165-
private int quarterWidth;
164+
private const float HalfWidth = 256f;
166165

167166
private float timeLastUpdatedBuilds;
168167

@@ -189,7 +188,7 @@ private static bool IsHoloLensConnectedUsb
189188
public static void OpenWindow()
190189
{
191190
// Dock it next to the Scene View.
192-
var window = GetWindow<BuildDeployWindow>(typeof(SceneView));
191+
var window = GetWindow<UwpBuildDeployWindow>(typeof(SceneView));
193192
window.titleContent = new GUIContent("Build Window");
194193
window.Show();
195194
}
@@ -225,9 +224,6 @@ private void Setup()
225224

226225
private void OnGUI()
227226
{
228-
quarterWidth = Screen.width / 4;
229-
halfWidth = Screen.width / 2;
230-
231227
#region Quick Options
232228

233229
if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.WSAPlayer)
@@ -249,14 +245,14 @@ private void OnGUI()
249245

250246
GUI.enabled = Directory.Exists(BuildDeployPreferences.AbsoluteBuildDirectory);
251247

252-
if (GUILayout.Button("Open Build Directory", GUILayout.Width(quarterWidth)))
248+
if (GUILayout.Button("Open Build Directory"))
253249
{
254250
EditorApplication.delayCall += () => Process.Start(BuildDeployPreferences.AbsoluteBuildDirectory);
255251
}
256252

257253
GUI.enabled = true;
258254

259-
if (GUILayout.Button("Open Player Settings", GUILayout.Width(quarterWidth)))
255+
if (GUILayout.Button("Open Player Settings"))
260256
{
261257
EditorApplication.ExecuteMenuItem("Edit/Project Settings/Player");
262258
}
@@ -283,14 +279,14 @@ private void OnGUI()
283279
GUI.enabled = ShouldBuildSLNBeEnabled;
284280

285281
// Build & Run button...
286-
if (GUILayout.Button(CanInstall ? buildAllThenInstallLabel : buildAllLabel, GUILayout.Width(halfWidth - 20)))
282+
if (GUILayout.Button(CanInstall ? buildAllThenInstallLabel : buildAllLabel, GUILayout.Width(HalfWidth), GUILayout.ExpandWidth(true)))
287283
{
288284
EditorApplication.delayCall += () => BuildAll(canInstall);
289285
}
290286

291287
GUI.enabled = true;
292288

293-
if (GUILayout.Button("Open Player Settings", GUILayout.Width(quarterWidth)))
289+
if (GUILayout.Button("Open Player Settings"))
294290
{
295291
EditorApplication.ExecuteMenuItem("Edit/Project Settings/Player");
296292
}
@@ -349,7 +345,7 @@ private void UnityBuildGUI()
349345

350346
GUI.enabled = Directory.Exists(BuildDeployPreferences.AbsoluteBuildDirectory);
351347

352-
if (GUILayout.Button("Open Build Directory", GUILayout.Width(halfWidth)))
348+
if (GUILayout.Button("Open Build Directory", GUILayout.Width(HalfWidth)))
353349
{
354350
EditorApplication.delayCall += () => Process.Start(BuildDeployPreferences.AbsoluteBuildDirectory);
355351
}
@@ -358,11 +354,26 @@ private void UnityBuildGUI()
358354

359355
EditorGUILayout.EndHorizontal();
360356
EditorGUILayout.BeginHorizontal();
357+
358+
// Generate C# Project References for debugging
359+
bool generateReferenceProjects = EditorUserBuildSettings.wsaGenerateReferenceProjects;
360+
361+
var curScriptingBackend = PlayerSettings.GetScriptingBackend(BuildTargetGroup.WSA);
362+
363+
GUI.enabled = curScriptingBackend == ScriptingImplementation.WinRTDotNET;
364+
bool shouldGenerateProjects = EditorGUILayout.Toggle(useCSharpProjectsLabel, generateReferenceProjects);
365+
GUI.enabled = true;
366+
367+
if (shouldGenerateProjects != generateReferenceProjects)
368+
{
369+
EditorUserBuildSettings.wsaGenerateReferenceProjects = shouldGenerateProjects;
370+
}
371+
361372
GUILayout.FlexibleSpace();
362373

363374
GUI.enabled = ShouldOpenSLNBeEnabled;
364375

365-
if (GUILayout.Button("Open in Visual Studio", GUILayout.Width(halfWidth)))
376+
if (GUILayout.Button("Open in Visual Studio", GUILayout.Width(HalfWidth)))
366377
{
367378
// Open SLN
368379
string slnFilename = Path.Combine(BuildDeployPreferences.BuildDirectory, $"{PlayerSettings.productName}.sln");
@@ -381,40 +392,24 @@ private void UnityBuildGUI()
381392
}
382393

383394
EditorGUILayout.EndHorizontal();
384-
EditorGUILayout.BeginHorizontal();
385-
386-
// Generate C# Project References for debugging
387-
GUILayout.FlexibleSpace();
388-
var previousLabelWidth = EditorGUIUtility.labelWidth;
389-
EditorGUIUtility.labelWidth = 105;
390-
bool generateReferenceProjects = EditorUserBuildSettings.wsaGenerateReferenceProjects;
391-
bool shouldGenerateProjects = EditorGUILayout.Toggle(useCSharpProjectsLabel, generateReferenceProjects);
392-
393-
if (shouldGenerateProjects != generateReferenceProjects)
394-
{
395-
EditorUserBuildSettings.wsaGenerateReferenceProjects = shouldGenerateProjects;
396-
}
397-
398-
EditorGUIUtility.labelWidth = previousLabelWidth;
395+
EditorGUILayout.Space();
399396

400397
// Build Unity Player
401398
GUI.enabled = ShouldBuildSLNBeEnabled;
402399

403-
if (GUILayout.Button("Build Unity Project", GUILayout.Width(halfWidth)))
400+
if (GUILayout.Button("Build Unity Project"))
404401
{
405402
EditorApplication.delayCall += BuildUnityProject;
406403
}
407404

408405
GUI.enabled = true;
409406

410-
EditorGUILayout.EndHorizontal();
411407
EditorGUILayout.EndVertical();
412408
}
413409

414410
private void AppxBuildGUI()
415411
{
416412
GUILayout.BeginVertical();
417-
GUILayout.BeginHorizontal();
418413

419414
// SDK and MS Build Version(and save setting, if it's changed)
420415
string currentSDKVersion = EditorUserBuildSettings.wsaUWPSDK;
@@ -436,7 +431,7 @@ private void AppxBuildGUI()
436431
}
437432
}
438433

439-
EditorGUILayout.LabelField("Required SDK Version: " + SdkVersion, GUILayout.Width(halfWidth - 16));
434+
EditorGUILayout.HelpBox("Required SDK Version: " + SdkVersion, MessageType.Info);
440435

441436
// Throw exception if user has no Windows 10 SDK installed
442437
if (currentSDKVersionIndex < 0)
@@ -446,7 +441,6 @@ private void AppxBuildGUI()
446441
Debug.LogError($"Unable to find the required Windows 10 SDK Target!\nPlease be sure to install the {SdkVersion} SDK from Visual Studio Installer.");
447442
}
448443

449-
GUILayout.EndHorizontal();
450444
EditorGUILayout.HelpBox($"Unable to find the required Windows 10 SDK Target!\nPlease be sure to install the {SdkVersion} SDK from Visual Studio Installer.", MessageType.Error);
451445
GUILayout.EndVertical();
452446
IsValidSdkInstalled = false;
@@ -460,17 +454,9 @@ private void AppxBuildGUI()
460454
if (curScriptingBackend == ScriptingImplementation.WinRTDotNET)
461455
{
462456
EditorGUILayout.HelpBox(".NET Scripting backend is depreciated, please use IL2CPP.", MessageType.Warning);
463-
GUILayout.EndHorizontal();
464-
GUILayout.BeginHorizontal();
465-
GUILayout.FlexibleSpace();
466457
}
467458

468-
var newScriptingBackend = (ScriptingImplementation)EditorGUILayout.IntPopup(
469-
"Scripting Backend",
470-
(int)curScriptingBackend,
471-
scriptingBackendNames,
472-
scriptingBackendEnum,
473-
GUILayout.Width(halfWidth));
459+
var newScriptingBackend = (ScriptingImplementation)EditorGUILayout.IntPopup("Scripting Backend", (int)curScriptingBackend, scriptingBackendNames, scriptingBackendEnum, GUILayout.Width(HalfWidth));
474460

475461
if (newScriptingBackend != curScriptingBackend)
476462
{
@@ -498,10 +484,6 @@ private void AppxBuildGUI()
498484
EditorUserBuildSettings.wsaUWPSDK = newSDKVersion;
499485
}
500486

501-
GUILayout.EndHorizontal();
502-
GUILayout.BeginHorizontal();
503-
GUILayout.FlexibleSpace();
504-
505487
// Build config (and save setting, if it's changed)
506488
string curBuildConfigString = BuildDeployPreferences.BuildConfig;
507489

@@ -520,7 +502,7 @@ private void AppxBuildGUI()
520502
}
521503

522504
EditorUserBuildSettings.GetWSADotNetNative(buildConfigOption);
523-
buildConfigOption = (WSABuildType)EditorGUILayout.EnumPopup("Build Configuration", buildConfigOption, GUILayout.Width(halfWidth));
505+
buildConfigOption = (WSABuildType)EditorGUILayout.EnumPopup("Build Configuration", buildConfigOption, GUILayout.Width(HalfWidth));
524506

525507
string buildConfigString = buildConfigOption.ToString();
526508

@@ -529,10 +511,6 @@ private void AppxBuildGUI()
529511
BuildDeployPreferences.BuildConfig = buildConfigString;
530512
}
531513

532-
GUILayout.EndHorizontal();
533-
GUILayout.BeginHorizontal();
534-
GUILayout.FlexibleSpace();
535-
536514
// Build Platform (and save setting, if it's changed)
537515
string curBuildPlatformString = BuildDeployPreferences.BuildPlatform;
538516
var buildPlatformOption = BuildPlatformEnum.x86;
@@ -546,7 +524,7 @@ private void AppxBuildGUI()
546524
buildPlatformOption = BuildPlatformEnum.x64;
547525
}
548526

549-
buildPlatformOption = (BuildPlatformEnum)EditorGUILayout.EnumPopup("Build Platform", buildPlatformOption, GUILayout.Width(halfWidth));
527+
buildPlatformOption = (BuildPlatformEnum)EditorGUILayout.EnumPopup("Build Platform", buildPlatformOption, GUILayout.Width(HalfWidth));
550528

551529
string newBuildPlatformString;
552530

@@ -565,9 +543,7 @@ private void AppxBuildGUI()
565543
BuildDeployPreferences.BuildPlatform = newBuildPlatformString;
566544
}
567545

568-
GUILayout.EndHorizontal();
569546
GUILayout.BeginHorizontal();
570-
GUILayout.FlexibleSpace();
571547

572548
var previousLabelWidth = EditorGUIUtility.labelWidth;
573549

@@ -589,17 +565,33 @@ private void AppxBuildGUI()
589565

590566
EditorGUI.BeginChangeCheck();
591567

592-
newVersion.x = EditorGUILayout.IntField(PlayerSettings.WSA.packageVersion.Major, GUILayout.Width(quarterWidth / 2 - 3));
593-
newVersion.y = EditorGUILayout.IntField(PlayerSettings.WSA.packageVersion.Minor, GUILayout.Width(quarterWidth / 2 - 3));
594-
newVersion.z = EditorGUILayout.IntField(PlayerSettings.WSA.packageVersion.Build, GUILayout.Width(quarterWidth / 2 - 3));
568+
newVersion.x = EditorGUILayout.IntField(PlayerSettings.WSA.packageVersion.Major);
569+
newVersion.y = EditorGUILayout.IntField(PlayerSettings.WSA.packageVersion.Minor);
570+
newVersion.z = EditorGUILayout.IntField(PlayerSettings.WSA.packageVersion.Build);
595571

596572
if (EditorGUI.EndChangeCheck())
597573
{
598574
PlayerSettings.WSA.packageVersion = new Version((int)newVersion.x, (int)newVersion.y, (int)newVersion.z, 0);
599575
}
600576

601577
GUI.enabled = false;
602-
EditorGUILayout.IntField(PlayerSettings.WSA.packageVersion.Revision, GUILayout.Width(quarterWidth / 2 - 3));
578+
EditorGUILayout.IntField(PlayerSettings.WSA.packageVersion.Revision);
579+
GUI.enabled = true;
580+
581+
GUILayout.EndHorizontal();
582+
GUILayout.BeginHorizontal();
583+
GUILayout.FlexibleSpace();
584+
585+
// Open AppX packages location
586+
string appxDirectory = curScriptingBackend == ScriptingImplementation.IL2CPP ? $"/AppPackages/{PlayerSettings.productName}" : $"/{PlayerSettings.productName}/AppPackages";
587+
string appxBuildPath = Path.GetFullPath($"{BuildDeployPreferences.BuildDirectory}{appxDirectory}");
588+
GUI.enabled = builds.Count > 0 && !string.IsNullOrEmpty(appxBuildPath);
589+
590+
if (GUILayout.Button("Open APPX Packages Location", GUILayout.Width(HalfWidth)))
591+
{
592+
EditorApplication.delayCall += () => Process.Start("explorer.exe", $"/f /open,{appxBuildPath}");
593+
}
594+
603595
GUI.enabled = true;
604596

605597
GUILayout.EndHorizontal();
@@ -623,7 +615,7 @@ private void AppxBuildGUI()
623615
// Build APPX
624616
GUI.enabled = ShouldBuildAppxBeEnabled;
625617

626-
if (GUILayout.Button("Build APPX", GUILayout.Width(halfWidth)))
618+
if (GUILayout.Button("Build APPX", GUILayout.Width(HalfWidth)))
627619
{
628620
// Check if solution exists
629621
string slnFilename = Path.Combine(BuildDeployPreferences.BuildDirectory, $"{PlayerSettings.productName}.sln");
@@ -640,22 +632,6 @@ private void AppxBuildGUI()
640632
GUI.enabled = true;
641633
}
642634

643-
GUILayout.EndHorizontal();
644-
GUILayout.BeginHorizontal();
645-
GUILayout.FlexibleSpace();
646-
647-
// Open AppX packages location
648-
string appxDirectory = curScriptingBackend == ScriptingImplementation.IL2CPP ? $"/AppPackages/{PlayerSettings.productName}" : $"/{PlayerSettings.productName}/AppPackages";
649-
string appxBuildPath = Path.GetFullPath($"{BuildDeployPreferences.BuildDirectory}{appxDirectory}");
650-
GUI.enabled = builds.Count > 0 && !string.IsNullOrEmpty(appxBuildPath);
651-
652-
if (GUILayout.Button("Open APPX Packages Location", GUILayout.Width(halfWidth)))
653-
{
654-
EditorApplication.delayCall += () => Process.Start("explorer.exe", $"/f /open,{appxBuildPath}");
655-
}
656-
657-
GUI.enabled = true;
658-
659635
GUILayout.EndHorizontal();
660636
GUILayout.EndVertical();
661637
}
@@ -664,6 +640,7 @@ private void DeployGUI()
664640
{
665641
Debug.Assert(portalConnections.Connections.Count != 0);
666642
Debug.Assert(currentConnectionInfoIndex >= 0);
643+
667644
if (currentConnectionInfoIndex > portalConnections.Connections.Count - 1)
668645
{
669646
currentConnectionInfoIndex = 0;
@@ -675,7 +652,7 @@ private void DeployGUI()
675652

676653
GUI.enabled = IsHoloLensConnectedUsb;
677654

678-
if (GUILayout.Button(pairHoloLensUsbLabel, GUILayout.Width(quarterWidth)))
655+
if (GUILayout.Button(pairHoloLensUsbLabel, GUILayout.Width(128f)))
679656
{
680657
EditorApplication.delayCall += PairDevice;
681658
}
@@ -689,7 +666,7 @@ private void DeployGUI()
689666
bool useSSL = EditorGUILayout.Toggle(useSSLLabel, BuildDeployPreferences.UseSSL);
690667
EditorGUIUtility.labelWidth = previousLabelWidth;
691668

692-
currentConnectionInfoIndex = EditorGUILayout.Popup(currentConnectionInfoIndex, targetIps, GUILayout.Width(halfWidth - 48));
669+
currentConnectionInfoIndex = EditorGUILayout.Popup(currentConnectionInfoIndex, targetIps);
693670

694671
var currentConnection = portalConnections.Connections[currentConnectionInfoIndex];
695672
bool currentConnectionIsLocal = IsLocalConnection(currentConnection);
@@ -726,7 +703,7 @@ private void DeployGUI()
726703
GUILayout.BeginHorizontal();
727704
GUILayout.FlexibleSpace();
728705

729-
GUILayout.Label(currentConnection.MachineName, GUILayout.Width(halfWidth));
706+
GUILayout.Label(currentConnection.MachineName, GUILayout.Width(HalfWidth));
730707

731708
GUILayout.EndHorizontal();
732709

@@ -736,17 +713,17 @@ private void DeployGUI()
736713
GUILayout.FlexibleSpace();
737714

738715
GUI.enabled = !currentConnectionIsLocal;
739-
currentConnection.IP = EditorGUILayout.TextField(ipAddressLabel, currentConnection.IP, GUILayout.Width(halfWidth));
716+
currentConnection.IP = EditorGUILayout.TextField(ipAddressLabel, currentConnection.IP, GUILayout.Width(HalfWidth));
740717
GUI.enabled = true;
741718

742719
GUILayout.EndHorizontal();
743720
GUILayout.BeginHorizontal();
744721
GUILayout.FlexibleSpace();
745-
currentConnection.User = EditorGUILayout.TextField("Username", currentConnection.User, GUILayout.Width(halfWidth));
722+
currentConnection.User = EditorGUILayout.TextField("Username", currentConnection.User, GUILayout.Width(HalfWidth));
746723
GUILayout.EndHorizontal();
747724
GUILayout.BeginHorizontal();
748725
GUILayout.FlexibleSpace();
749-
currentConnection.Password = EditorGUILayout.PasswordField("Password", currentConnection.Password, GUILayout.Width(halfWidth));
726+
currentConnection.Password = EditorGUILayout.PasswordField("Password", currentConnection.Password, GUILayout.Width(HalfWidth));
750727
GUILayout.EndHorizontal();
751728
GUILayout.BeginHorizontal();
752729

@@ -784,7 +761,7 @@ private void DeployGUI()
784761
{
785762
GUI.enabled = IsValidIpAddress(currentConnection.IP) && IsCredentialsValid(currentConnection);
786763

787-
if (GUILayout.Button("Connect", GUILayout.Width(quarterWidth)))
764+
if (GUILayout.Button("Connect"))
788765
{
789766
EditorApplication.delayCall += () =>
790767
{
@@ -798,7 +775,7 @@ private void DeployGUI()
798775
GUI.enabled = DevicePortalConnectionEnabled && CanInstall;
799776

800777
// Open web portal
801-
if (GUILayout.Button("Open Device Portal", GUILayout.Width(quarterWidth)))
778+
if (GUILayout.Button("Open Device Portal", GUILayout.Width(128f)))
802779
{
803780
EditorApplication.delayCall += () => OpenDevicePortal(portalConnections, currentConnection);
804781
}

Assets/MixedRealityToolkit/_Core/Utilities/BuildAndDeploy/BuildDeployWindow.cs.meta renamed to Assets/MixedRealityToolkit/_Core/Utilities/BuildAndDeploy/UwpBuildDeployWindow.cs.meta

File renamed without changes.

0 commit comments

Comments
 (0)