Skip to content

Commit 5d1eb68

Browse files
authored
Merge pull request #1 from Microsoft/master
Pull back
2 parents b343867 + 383bb71 commit 5d1eb68

File tree

10 files changed

+120
-43
lines changed

10 files changed

+120
-43
lines changed

Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployPrefs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static string BuildConfig
4545

4646
public static string BuildPlatform
4747
{
48-
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_BuildPlatform, "Any CPU"); }
48+
get { return EditorPrefsUtility.GetEditorPref(EditorPrefs_BuildPlatform, "x86"); }
4949
set { EditorPrefsUtility.SetEditorPref(EditorPrefs_BuildPlatform, value); }
5050
}
5151

Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployTools.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,32 @@ public static bool IsIl2CppAvailable()
4242
return Directory.Exists(EditorApplication.applicationContentsPath + "\\PlaybackEngines\\MetroSupport\\Managed\\il2cpp");
4343
}
4444

45+
/// <summary>
46+
/// Displays a dialog if no scenes are present in the build and returns true if build can proceed.
47+
/// </summary>
48+
/// <returns></returns>
49+
public static bool CheckBuildScenes()
50+
{
51+
if (EditorBuildSettings.scenes.Length == 0)
52+
{
53+
return EditorUtility.DisplayDialog("Attention!",
54+
"No scenes are present in the build settings!\n\n Do you want to cancel and add one?",
55+
"Continue Anyway", "Cancel Build");
56+
}
57+
58+
return true;
59+
}
60+
4561
public static bool BuildSLN(string buildDirectory, bool showDialog = true)
4662
{
4763
// Use BuildSLNUtilities to create the SLN
4864
bool buildSuccess = false;
4965

66+
if (CheckBuildScenes() == false)
67+
{
68+
return false;
69+
}
70+
5071
var buildInfo = new BuildInfo
5172
{
5273
// These properties should all match what the Standalone.proj file specifies

Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployWindow.cs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private bool ShouldWebPortalBeEnabled
6969

7070
private bool ShouldLogViewBeEnabled
7171
{
72-
get { return !string.IsNullOrEmpty(BuildDeployPrefs.TargetIPs) && !string.IsNullOrEmpty(BuildDeployPrefs.BuildDirectory); }
72+
get { return !string.IsNullOrEmpty(BuildDeployPrefs.BuildDirectory); }
7373
}
7474

7575
private bool LocalIPsOnly { get { return true; } }
@@ -327,6 +327,18 @@ private void OnGUI()
327327

328328
currentSDKVersionIndex = EditorGUILayout.Popup(GUIHorizontalSpacer + "SDK Version", currentSDKVersionIndex, windowsSdkPaths);
329329

330+
var curScriptingBackend = PlayerSettings.GetScriptingBackend(BuildTargetGroup.WSA);
331+
var newScriptingBackend = (ScriptingImplementation)EditorGUILayout.IntPopup(
332+
GUIHorizontalSpacer + "Scripting Backend",
333+
(int)curScriptingBackend,
334+
new[] { "IL2CPP", ".NET" },
335+
new[] { (int)ScriptingImplementation.IL2CPP, (int)ScriptingImplementation.WinRTDotNET });
336+
337+
if (newScriptingBackend != curScriptingBackend)
338+
{
339+
PlayerSettings.SetScriptingBackend(BuildTargetGroup.WSA, newScriptingBackend);
340+
}
341+
330342
string newSDKVersion = windowsSdkPaths[currentSDKVersionIndex];
331343

332344
if (!newSDKVersion.Equals(currentSDKVersion))
@@ -335,7 +347,6 @@ private void OnGUI()
335347
}
336348

337349
string newMSBuildVer = currentSDKVersionIndex <= defaultMSBuildVersionIndex ? BuildDeployTools.DefaultMSBuildVersion : "15.0";
338-
EditorGUILayout.LabelField(GUIHorizontalSpacer + "MS Build Version", newMSBuildVer);
339350

340351
if (!newMSBuildVer.Equals(curMSBuildVer))
341352
{
@@ -672,12 +683,30 @@ private void OnGUI()
672683
// Log file
673684
using (new EditorGUILayout.HorizontalScope())
674685
{
675-
GUI.enabled = ShouldLogViewBeEnabled && (!locatorIsSearching && locatorHasData || HoloLensUsbConnected);
686+
string localLogPath = string.Empty;
687+
bool localLogExists = false;
688+
689+
bool remoteDeviceDetected = !locatorIsSearching && locatorHasData || HoloLensUsbConnected && !string.IsNullOrEmpty(BuildDeployPrefs.TargetIPs);
690+
bool isLocalBuild = BuildDeployPrefs.BuildPlatform == BuildPlatformEnum.x64.ToString();
691+
if (!remoteDeviceDetected)
692+
{
693+
localLogPath = string.Format("%USERPROFILE%\\AppData\\Local\\Packages\\{0}\\TempState\\UnityPlayer.log", PlayerSettings.productName);
694+
localLogExists = File.Exists(localLogPath);
695+
}
696+
697+
GUI.enabled = ShouldLogViewBeEnabled && (remoteDeviceDetected || isLocalBuild && localLogExists);
676698
GUILayout.FlexibleSpace();
677699

678700
if (GUILayout.Button("View Log File", GUILayout.Width(buttonWidth_Full)))
679701
{
680-
OpenLogFileForIPs(curTargetIps);
702+
if (remoteDeviceDetected)
703+
{
704+
OpenLogFileForIPs(curTargetIps);
705+
}
706+
else
707+
{
708+
Process.Start(localLogPath);
709+
}
681710
}
682711

683712
GUI.enabled = true;

Assets/HoloToolkit/BuildAndDeploy/Editor/BuildSLNUtilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public static void PerformBuild_CommandLine()
278278
// Use scenes from the editor build settings.
279279
Scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(scene => scene.path),
280280

281-
// Configure a post build action to throw appropreate error code.
281+
// Configure a post build action to throw appropriate error code.
282282
PostBuildAction = (innerBuildInfo, buildError) =>
283283
{
284284
if (!string.IsNullOrEmpty(buildError))

Assets/HoloToolkit/Utilities/Scripts/Editor/AutoConfigureMenu.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static void ShowSceneSettingsWindow()
4444
/// <summary>
4545
/// Applies recommended project settings to the current project
4646
/// </summary>
47-
[MenuItem("Mixed Reality Toolkit/Configure/Apply Mixed Reality Project Settings", false, 1)]
47+
[MenuItem("Mixed Reality Toolkit/Configure/Apply Mixed Reality Project Settings", false, 0)]
4848
public static void ShowProjectSettingsWindow()
4949
{
5050
var window = (ProjectSettingsWindow)EditorWindow.GetWindow(typeof(ProjectSettingsWindow), true, "Apply Mixed Reality Project Settings");
@@ -73,4 +73,4 @@ public void OnActiveBuildTargetChanged(BuildTarget previousTarget, BuildTarget n
7373
}
7474
#endif
7575
}
76-
}
76+
}

Assets/HoloToolkit/Utilities/Scripts/Editor/ProjectSettingsWindow.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,11 @@ private void UpdateSettings(BuildTarget currentBuildTarget)
102102
{
103103
using (var webRequest = UnityWebRequest.Get(SharingServiceURL))
104104
{
105+
#if UNITY_2017_2_OR_NEWER
106+
webRequest.SendWebRequest();
107+
#else
105108
webRequest.Send();
106-
109+
#endif
107110
while (!webRequest.isDone)
108111
{
109112
if (webRequest.downloadProgress != -1)
@@ -162,7 +165,11 @@ private void UpdateSettings(BuildTarget currentBuildTarget)
162165
{
163166
using (var webRequest = UnityWebRequest.Get(InputManagerAssetURL))
164167
{
168+
#if UNITY_2017_2_OR_NEWER
169+
webRequest.SendWebRequest();
170+
#else
165171
webRequest.Send();
172+
#endif
166173

167174
while (!webRequest.isDone)
168175
{
@@ -227,6 +234,7 @@ private void UpdateSettings(BuildTarget currentBuildTarget)
227234
EditorUserBuildSettings.wsaSubtarget = WSASubtarget.AnyDevice;
228235
UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.WSA, new[] { "None" });
229236
PlayerSettings.WSA.SetCapability(PlayerSettings.WSACapability.HumanInterfaceDevice, false);
237+
BuildDeployPrefs.BuildPlatform = "Any CPU";
230238
}
231239
else
232240
{
@@ -238,6 +246,7 @@ private void UpdateSettings(BuildTarget currentBuildTarget)
238246
EditorUserBuildSettings.wsaSubtarget = WSASubtarget.HoloLens;
239247
UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.WSA, new[] { "HoloLens" });
240248
PlayerSettings.WSA.SetCapability(PlayerSettings.WSACapability.HumanInterfaceDevice, Values[ProjectSetting.XboxControllerSupport]);
249+
BuildDeployPrefs.BuildPlatform = "x86";
241250

242251
for (var i = 0; i < QualitySettings.names.Length; i++)
243252
{
@@ -249,6 +258,7 @@ private void UpdateSettings(BuildTarget currentBuildTarget)
249258
EditorUserBuildSettings.wsaSubtarget = WSASubtarget.PC;
250259
UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.WSA, new[] { "stereo" });
251260
PlayerSettings.WSA.SetCapability(PlayerSettings.WSACapability.HumanInterfaceDevice, false);
261+
BuildDeployPrefs.BuildPlatform = "x64";
252262

253263
for (var i = 0; i < QualitySettings.names.Length; i++)
254264
{

Assets/HoloToolkit/Utilities/Scripts/Editor/SceneSettingsWindow.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ protected override void ApplySettings()
3333
{
3434
if (Values[SceneSetting.AddMixedRealityCamera])
3535
{
36-
Instantiate(AssetDatabase.LoadAssetAtPath<GameObject>(AssetDatabase.GUIDToAssetPath(CameraPrefabGUID)));
36+
DestroyImmediate(Camera.main.gameObject);
37+
PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath<GameObject>(AssetDatabase.GUIDToAssetPath(CameraPrefabGUID)));
3738
}
3839

3940
var mainCamera = CameraCache.Refresh(Camera.main);
@@ -55,7 +56,7 @@ protected override void ApplySettings()
5556

5657
protected override void LoadSettings()
5758
{
58-
for (int i = (int)SceneSetting.CameraToOrigin; i <= (int)SceneSetting.CameraToOrigin; i++)
59+
for (int i = 0; i <= (int)SceneSetting.CameraToOrigin; i++)
5960
{
6061
Values[(SceneSetting)i] = true;
6162
}

Assets/HoloToolkit/Utilities/Scripts/Editor/SetIconsWindow.cs

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,19 @@ private static string CloneAndResizeToFile(PlayerSettings.WSAImageType type, Pla
272272

273273
// Resize clone to desired size
274274
TextureScale.Bilinear(clone, (int)iconSize.x, (int)iconSize.y);
275-
clone.Compress(true);
276-
AssetDatabase.SaveAssets();
277275

278-
if (clone.GetRawTextureData().Length > 204800)
276+
// Crop
277+
Color[] pix = clone.GetPixels(0, 0, (int)iconSize.x, (int)iconSize.y);
278+
clone = new Texture2D((int)iconSize.x, (int)iconSize.y, TextureFormat.ARGB32, false);
279+
clone.SetPixels(pix);
280+
clone.Apply();
281+
282+
var rawData = clone.EncodeToPNG();
283+
File.WriteAllBytes(filePath, rawData);
284+
285+
if (rawData.Length > 204800)
279286
{
280287
Debug.LogWarningFormat("{0} exceeds the minimum file size of 204,800 bytes, please use a smaller image for generating your icons.", clone.name);
281-
return string.Empty;
282288
}
283289
}
284290
catch (Exception e)
@@ -335,63 +341,61 @@ private static Vector2 GetUWPImageTypeSize(PlayerSettings.WSAImageType type, Pla
335341
switch (scale)
336342
{
337343
case PlayerSettings.WSAImageScale.Target16:
338-
return CreateSize(16);
344+
return CreateSquareSize(16);
339345
case PlayerSettings.WSAImageScale.Target24:
340-
return CreateSize(24);
346+
return CreateSquareSize(24);
341347
case PlayerSettings.WSAImageScale.Target32:
342-
return CreateSize(32);
348+
return CreateSquareSize(32);
343349
case PlayerSettings.WSAImageScale.Target48:
344-
return CreateSize(48);
350+
return CreateSquareSize(48);
345351
case PlayerSettings.WSAImageScale.Target256:
346-
return CreateSize(256);
352+
return CreateSquareSize(256);
347353
default:
348354
return GetWSAImageTypeSize(type, scale);
349355
}
350356
}
351357

352358
private static Vector2 GetWSAImageTypeSize(PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale)
353359
{
360+
float scaleFactor = float.Parse(scale.ToString().Replace("_", "")) * 0.01f;
361+
354362
switch (type)
355363
{
356364
case PlayerSettings.WSAImageType.PackageLogo:
357-
return CreateSize(50);
365+
return CreateSquareSize(50, scaleFactor);
358366
case PlayerSettings.WSAImageType.StoreTileLogo:
359-
return CreateSize(150);
367+
return CreateSquareSize(150, scaleFactor);
360368
case PlayerSettings.WSAImageType.StoreTileSmallLogo:
361-
return CreateSize(30);
369+
return CreateSquareSize(30, scaleFactor);
362370
case PlayerSettings.WSAImageType.StoreSmallTile:
363-
return CreateSize(70);
371+
return CreateSquareSize(70, scaleFactor);
364372
case PlayerSettings.WSAImageType.StoreLargeTile:
365-
return CreateSize(310);
373+
return CreateSquareSize(310, scaleFactor);
366374
case PlayerSettings.WSAImageType.PhoneAppIcon:
367-
return CreateSize(44);
375+
return CreateSquareSize(44, scaleFactor);
368376
case PlayerSettings.WSAImageType.PhoneSmallTile:
369-
return CreateSize(71);
377+
return CreateSquareSize(71, scaleFactor);
370378
case PlayerSettings.WSAImageType.PhoneMediumTile:
371-
return CreateSize(150);
379+
return CreateSquareSize(150, scaleFactor);
372380
case PlayerSettings.WSAImageType.UWPSquare44x44Logo:
373-
return CreateSize(44);
381+
return CreateSquareSize(44, scaleFactor);
374382
case PlayerSettings.WSAImageType.UWPSquare71x71Logo:
375-
return CreateSize(71);
383+
return CreateSquareSize(71, scaleFactor);
376384
case PlayerSettings.WSAImageType.UWPSquare150x150Logo:
377-
return CreateSize(150);
385+
return CreateSquareSize(150, scaleFactor);
378386
case PlayerSettings.WSAImageType.UWPSquare310x310Logo:
379-
return CreateSize(310);
387+
return CreateSquareSize(310, scaleFactor);
380388

381389
// WIDE 31:15
382390
case PlayerSettings.WSAImageType.PhoneWideTile:
383391
case PlayerSettings.WSAImageType.StoreTileWideLogo:
384392
case PlayerSettings.WSAImageType.UWPWide310x150Logo:
385-
return new Vector2(310, 150);
393+
return CreateSize(new Vector2(310, 150), scaleFactor);
386394
case PlayerSettings.WSAImageType.SplashScreenImage:
387-
return new Vector2(620, 300);
395+
return CreateSize(new Vector2(620, 300), scaleFactor);
388396
case PlayerSettings.WSAImageType.PhoneSplashScreen:
389397
default:
390-
var size = Vector2.zero;
391-
float scaleFactor = float.Parse(scale.ToString().Replace("_", "")) * 0.01f;
392-
size = size * scaleFactor;
393-
size.x = (float)Math.Ceiling(size.x);
394-
size.y = (float)Math.Ceiling(size.y);
398+
var size = CreateSquareSize(0, scaleFactor);
395399

396400
if (size == Vector2.zero)
397401
{
@@ -402,9 +406,20 @@ private static Vector2 GetWSAImageTypeSize(PlayerSettings.WSAImageType type, Pla
402406
}
403407
}
404408

405-
private static Vector2 CreateSize(int size)
409+
private static Vector2 CreateSquareSize(int size, float scaleFactor = 0f)
410+
{
411+
var newSize = new Vector2(size * scaleFactor, size * scaleFactor);
412+
newSize.x = (float)Math.Ceiling(newSize.x);
413+
newSize.y = (float)Math.Ceiling(newSize.y);
414+
return newSize;
415+
}
416+
417+
private static Vector2 CreateSize(Vector2 size, float scaleFactor = 0f)
406418
{
407-
return new Vector2(size, size);
419+
var newSize = new Vector2(size.x * scaleFactor, size.y * scaleFactor);
420+
newSize.x = (float)Math.Ceiling(newSize.x);
421+
newSize.y = (float)Math.Ceiling(newSize.y);
422+
return newSize;
408423
}
409424
}
410425
}

Assets/HoloToolkit/Utilities/Scripts/Editor/TextureScale.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
// See http://wiki.unity3d.com/index.php/TextureScale
34

45
using System.Threading;
56
using UnityEngine;
@@ -107,7 +108,7 @@ private static void ThreadedScale(Texture2D tex, int newWidth, int newHeight, bo
107108
}
108109
}
109110

110-
tex.Resize(newWidth, newHeight, TextureFormat.RGB24, false);
111+
tex.Resize(newWidth, newHeight, TextureFormat.ARGB32, false);
111112
tex.SetPixels(newColors);
112113
tex.Apply();
113114

ProjectSettings/ProjectSettings.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ PlayerSettings:
577577
additionalIl2CppArgs:
578578
scriptingRuntimeVersion: 0
579579
apiCompatibilityLevelPerPlatform:
580-
Metro: 1
580+
Metro: 3
581581
m_RenderingPath: 1
582582
m_MobileRenderingPath: 1
583583
metroPackageName: MixedRealityToolkit-Unity

0 commit comments

Comments
 (0)