Skip to content

Commit 813d94b

Browse files
Merge pull request #887 from StephenHodgson/HTK-IconGenUpdate
Editor Utility Tools Update
2 parents beaae2c + 2e5b2b1 commit 813d94b

39 files changed

+955
-888
lines changed

Assets/HoloToolkit-UnitTests/Editor/Input.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

Assets/HoloToolkit-UnitTests/Input.meta

Lines changed: 0 additions & 3 deletions
This file was deleted.

Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployPortal.cs

Lines changed: 78 additions & 58 deletions
Large diffs are not rendered by default.
Lines changed: 28 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
1-
//
2-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
32
// Licensed under the MIT License. See LICENSE in the project root for license information.
4-
//
53

64
using System.IO;
7-
using UnityEditor;
85
using UnityEngine;
96

107
namespace HoloToolkit.Unity
118
{
129
public static class BuildDeployPrefs
1310
{
1411
// Constants
15-
private const string EditorPrefs_BuildDir = "BuildDeployWindow_BuildDir";
16-
private const string EditorPrefs_BuildConfig = "BuildDeployWindow_BuildConfig";
17-
private const string EditorPrefs_ForceRebuild = "BuildDeployWindow_ForceBuild";
18-
private const string EditorPrefs_IncrementBuildVersion = "BuildDeployWindow_IncrementBuildVersion";
19-
private const string EditorPrefs_MSBuildVer = "BuildDeployWindow_MSBuildVer";
20-
private const string EditorPrefs_TargetIPs = "BuildDeployWindow_DestIPs";
21-
private const string EditorPrefs_DeviceUser = "BuildDeployWindow_DeviceUser";
22-
private const string EditorPrefs_DevicePwd = "BuildDeployWindow_DevicePwd";
23-
private const string EditorPrefs_FullReinstall = "BuildDeployWindow_FullReinstall";
12+
private const string EditorPrefs_BuildDir = "_BuildDeployWindow_BuildDir";
13+
private const string EditorPrefs_BuildConfig = "_BuildDeployWindow_BuildConfig";
14+
private const string EditorPrefs_ForceRebuild = "_BuildDeployWindow_ForceBuild";
15+
private const string EditorPrefs_IncrementBuildVersion = "_BuildDeployWindow_IncrementBuildVersion";
16+
private const string EditorPrefs_MSBuildVer = "_BuildDeployWindow_MSBuildVer";
17+
private const string EditorPrefs_TargetIPs = "_BuildDeployWindow_DestIPs";
18+
private const string EditorPrefs_DeviceUser = "_BuildDeployWindow_DeviceUser";
19+
private const string EditorPrefs_DevicePwd = "_BuildDeployWindow_DevicePwd";
20+
private const string EditorPrefs_FullReinstall = "_BuildDeployWindow_FullReinstall";
2421

2522
public static string BuildDirectory
2623
{
27-
get { return GetEditorPref(EditorPrefs_BuildDir, "WindowsStoreApp"); }
28-
set { EditorPrefs.SetString(EditorPrefs_BuildDir, value); }
24+
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_BuildDir, "UWP"); }
25+
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_BuildDir, value); }
2926
}
3027

3128
public static string AbsoluteBuildDirectory
@@ -35,72 +32,50 @@ public static string AbsoluteBuildDirectory
3532

3633
public static string MsBuildVersion
3734
{
38-
get { return GetEditorPref(EditorPrefs_MSBuildVer, BuildDeployTools.DefaultMSBuildVersion); }
39-
set { EditorPrefs.SetString(EditorPrefs_MSBuildVer, value); }
35+
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_MSBuildVer, BuildDeployTools.DefaultMSBuildVersion); }
36+
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_MSBuildVer, value); }
4037
}
4138

4239
public static string BuildConfig
4340
{
44-
get { return GetEditorPref(EditorPrefs_BuildConfig, "Debug"); }
45-
set { EditorPrefs.SetString(EditorPrefs_BuildConfig, value); }
41+
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_BuildConfig, "Debug"); }
42+
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_BuildConfig, value); }
4643
}
4744

4845
public static bool ForceRebuild
4946
{
50-
get { return GetEditorPref(EditorPrefs_ForceRebuild, false); }
51-
set { EditorPrefs.SetBool(EditorPrefs_ForceRebuild, value); }
47+
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_ForceRebuild, false); }
48+
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_ForceRebuild, value); }
5249
}
5350

5451
public static bool IncrementBuildVersion
5552
{
56-
get { return GetEditorPref(EditorPrefs_IncrementBuildVersion, true); }
57-
set { EditorPrefs.SetBool(EditorPrefs_IncrementBuildVersion, value); }
53+
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_IncrementBuildVersion, true); }
54+
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_IncrementBuildVersion, value); }
5855
}
5956

6057
public static string TargetIPs
6158
{
62-
get { return GetEditorPref(EditorPrefs_TargetIPs, "127.0.0.1"); }
63-
set { EditorPrefs.SetString(EditorPrefs_TargetIPs, value); }
59+
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_TargetIPs, "127.0.0.1"); }
60+
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_TargetIPs, value); }
6461
}
6562

6663
public static string DeviceUser
6764
{
68-
get { return GetEditorPref(EditorPrefs_DeviceUser, ""); }
69-
set { EditorPrefs.SetString(EditorPrefs_DeviceUser, value); }
65+
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_DeviceUser, ""); }
66+
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_DeviceUser, value); }
7067
}
7168

7269
public static string DevicePassword
7370
{
74-
get { return GetEditorPref(EditorPrefs_DevicePwd, ""); }
75-
set { EditorPrefs.SetString(EditorPrefs_DevicePwd, value); }
71+
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_DevicePwd, ""); }
72+
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_DevicePwd, value); }
7673
}
7774

7875
public static bool FullReinstall
7976
{
80-
get { return GetEditorPref(EditorPrefs_FullReinstall, true); }
81-
set { EditorPrefs.SetBool(EditorPrefs_FullReinstall, value); }
82-
}
83-
84-
private static string GetEditorPref(string key, string defaultValue)
85-
{
86-
if (EditorPrefs.HasKey(key))
87-
{
88-
return EditorPrefs.GetString(key);
89-
}
90-
91-
EditorPrefs.SetString(key, defaultValue);
92-
return defaultValue;
93-
}
94-
95-
private static bool GetEditorPref(string key, bool defaultValue)
96-
{
97-
if (EditorPrefs.HasKey(key))
98-
{
99-
return EditorPrefs.GetBool(key);
100-
}
101-
102-
EditorPrefs.SetBool(key, defaultValue);
103-
return defaultValue;
77+
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_FullReinstall, true); }
78+
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_FullReinstall, value); }
10479
}
10580
}
10681
}

Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployTools.cs

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
//
55

66
using System;
7+
using System.Diagnostics;
78
using System.IO;
89
using System.Linq;
10+
using System.Xml.Linq;
11+
using Microsoft.Win32;
912
using UnityEditor;
1013
using UnityEngine;
11-
using System.Xml.Linq;
14+
using Debug = UnityEngine.Debug;
1215

1316
namespace HoloToolkit.Unity
1417
{
@@ -73,8 +76,8 @@ public static string CalcMSBuildPath(string msBuildVersion)
7376
{
7477
if (msBuildVersion.Equals("14.0"))
7578
{
76-
using (Microsoft.Win32.RegistryKey key =
77-
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
79+
using (RegistryKey key =
80+
Registry.LocalMachine.OpenSubKey(
7881
string.Format(@"Software\Microsoft\MSBuild\ToolsVersions\{0}", msBuildVersion)))
7982
{
8083
if (key == null)
@@ -88,37 +91,42 @@ public static string CalcMSBuildPath(string msBuildVersion)
8891
}
8992

9093
// For MSBuild 15+ we should to use vswhere to give us the correct instance
91-
string output = @"/C cd ""%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"" && vswhere -version " + msBuildVersion + " -products * -requires Microsoft.Component.MSBuild -property installationPath";
94+
string output = @"/C vswhere -version " + msBuildVersion + " -products * -requires Microsoft.Component.MSBuild -property installationPath";
9295

93-
var vswherePInfo = new System.Diagnostics.ProcessStartInfo
96+
// get the right program files path based on whether the pc is x86 or x64
97+
string programFiles = @"C:\Program Files\";
98+
if (Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE", EnvironmentVariableTarget.Machine) == "AMD64")
99+
{
100+
programFiles = @"C:\Program Files (x86)\";
101+
}
102+
103+
var vswherePInfo = new ProcessStartInfo
94104
{
95105
FileName = "cmd.exe",
96106
CreateNoWindow = true,
97107
UseShellExecute = false,
98108
RedirectStandardOutput = true,
99-
Arguments = output
109+
RedirectStandardError = false,
110+
Arguments = output,
111+
WorkingDirectory = programFiles + @"Microsoft Visual Studio\Installer"
100112
};
101113

102-
using (var vswhereP = new System.Diagnostics.Process())
114+
using (var vswhereP = new Process())
103115
{
104116
vswhereP.StartInfo = vswherePInfo;
105117
vswhereP.Start();
106118
output = vswhereP.StandardOutput.ReadToEnd();
107119
vswhereP.WaitForExit();
108-
vswhereP.Close();
109-
vswhereP.Dispose();
110120
}
111121

112-
string externalScriptingEditorPath = EditorPrefs.GetString("kScriptsDefaultApp");
113122
string[] paths = output.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
114123

115-
for (int i = 0; i < paths.Length; i++)
124+
// if there are multiple 2017 installs,
125+
// prefer enterprise, then pro, then community
126+
string bestPath = paths.OrderBy(p => p.ToLower().Contains("enterprise")).ThenBy(p => p.ToLower().Contains("professional")).First();
127+
if (File.Exists(bestPath + @"\MSBuild\" + msBuildVersion + @"\Bin\MSBuild.exe"))
116128
{
117-
paths[i] = paths[i].Replace(Environment.NewLine, "");
118-
if (externalScriptingEditorPath.Contains(paths[i]))
119-
{
120-
return paths[i] + @"\MSBuild\" + msBuildVersion + @"\Bin\MSBuild.exe";
121-
}
129+
return bestPath + @"\MSBuild\" + msBuildVersion + @"\Bin\MSBuild.exe";
122130
}
123131

124132
Debug.LogError("Unable to find a valid path to Visual Studio Instance!");
@@ -127,15 +135,15 @@ public static string CalcMSBuildPath(string msBuildVersion)
127135

128136
public static bool RestoreNugetPackages(string nugetPath, string storePath)
129137
{
130-
var nugetPInfo = new System.Diagnostics.ProcessStartInfo
138+
var nugetPInfo = new ProcessStartInfo
131139
{
132140
FileName = nugetPath,
133141
CreateNoWindow = true,
134142
UseShellExecute = false,
135143
Arguments = "restore \"" + storePath + "/project.json\""
136144
};
137145

138-
using (var nugetP = new System.Diagnostics.Process())
146+
using (var nugetP = new Process())
139147
{
140148
nugetP.StartInfo = nugetPInfo;
141149
nugetP.Start();
@@ -205,7 +213,7 @@ public static bool BuildAppxFromSLN(string productName, string msBuildVersion, b
205213
}
206214

207215
// Now do the actual build
208-
var pInfo = new System.Diagnostics.ProcessStartInfo
216+
var pInfo = new ProcessStartInfo
209217
{
210218
FileName = vs,
211219
CreateNoWindow = false,
@@ -218,7 +226,7 @@ public static bool BuildAppxFromSLN(string productName, string msBuildVersion, b
218226
// Uncomment out to debug by copying into command window
219227
//Debug.Log("\"" + vs + "\"" + " " + pInfo.Arguments);
220228

221-
var process = new System.Diagnostics.Process { StartInfo = pInfo };
229+
var process = new Process { StartInfo = pInfo };
222230

223231
try
224232
{
@@ -237,7 +245,7 @@ public static bool BuildAppxFromSLN(string productName, string msBuildVersion, b
237245
showDialog &&
238246
!EditorUtility.DisplayDialog("Build AppX", "AppX Build Successful!", "OK", "Open Project Folder"))
239247
{
240-
System.Diagnostics.Process.Start("explorer.exe", "/select," + storePath);
248+
Process.Start("explorer.exe", "/select," + storePath);
241249
}
242250

243251
if (process.ExitCode != 0)

Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployWindow.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,10 @@ private bool HoloLensUsbConnected
110110
[MenuItem("HoloToolkit/Build Window", false, 0)]
111111
public static void OpenWindow()
112112
{
113-
var window = GetWindow<BuildDeployWindow>("Build Window");
114-
115-
if (window != null)
116-
{
117-
window.Show();
118-
}
113+
// Dock it next to the Scene View.
114+
var window = GetWindow<BuildDeployWindow>(typeof(SceneView));
115+
window.titleContent = new GUIContent("Build Window");
116+
window.Show();
119117
}
120118

121119
private void OnEnable()
@@ -563,7 +561,7 @@ private void OnGUI()
563561

564562
if (GUILayout.Button("Open APPX Packages Location", GUILayout.Width(buttonWidth_Full)))
565563
{
566-
Process.Start("explorer.exe", "/open," + Path.GetFullPath(curBuildDirectory + "/" + PlayerSettings.productName + "/AppPackages"));
564+
Process.Start("explorer.exe", "/f /open," + Path.GetFullPath(curBuildDirectory + "/" + PlayerSettings.productName + "/AppPackages"));
567565
}
568566

569567
GUI.enabled = true;
@@ -770,7 +768,7 @@ private void InstallAppOnDevicesList(string buildPath, string[] targetList)
770768
EditorUtility.ClearProgressBar();
771769
}
772770

773-
private bool InstallApp(string buildPath, string targetDevice)
771+
private static bool InstallApp(string buildPath, string targetDevice)
774772
{
775773
// Get the appx path
776774
FileInfo[] files = new DirectoryInfo(buildPath).GetFiles("*.appx");

Assets/HoloToolkit/BuildAndDeploy/Editor/BuildSLNUtilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static void PerformBuild(BuildInfo buildInfo)
9292
if (buildInfo.HasAnySymbols(BuildSymbolRelease))
9393
{
9494
//Unity automatically adds the DEBUG symbol if the BuildOptions.Development flag is
95-
//specified. In order to have debug symbols and the RELEASE symbole we have to
95+
//specified. In order to have debug symbols and the RELEASE symbols we have to
9696
//inject the symbol Unity relies on to enable the /debug+ flag of csc.exe which is "DEVELOPMENT_BUILD"
9797
buildInfo.AppendSymbols("DEVELOPMENT_BUILD");
9898
}

Assets/HoloToolkit/SpatialMapping/Scripts/RemoteMapping/Editor/RoomMeshExporter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace HoloToolkit.Unity
99
{
1010
public static class RoomMeshExporter
1111
{
12-
private const string ExportDirectoryKey = "ExportDirectory";
12+
private const string ExportDirectoryKey = "_ExportDirectory";
1313
private const string ExportDirectoryDefault = "MeshExport";
1414
private const string ExportDialogErrorTitle = "Export Error";
1515
private const string WavefrontFileExtension = ".obj";
@@ -18,7 +18,7 @@ public static string ExportDirectory
1818
{
1919
get
2020
{
21-
return EditorPrefs.GetString(ExportDirectoryKey, ExportDirectoryDefault);
21+
return EditorPrefsUtility.GetEditorPref(ExportDirectoryKey, ExportDirectoryDefault);
2222
}
2323
set
2424
{
@@ -27,7 +27,7 @@ public static string ExportDirectory
2727
value = ExportDirectoryDefault;
2828
}
2929

30-
EditorPrefs.SetString(ExportDirectoryKey, value);
30+
EditorPrefsUtility.SetEditorPref(ExportDirectoryKey, value);
3131
}
3232
}
3333

Assets/HoloToolkit/Utilities/Editor.meta

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)