Skip to content

Commit 3c0e949

Browse files
authored
Merge pull request #9938 from keveleigh/fix-2021
Updates with Unity 2021 changes
2 parents 9845f9e + d9398ca commit 3c0e949

File tree

8 files changed

+50
-8
lines changed

8 files changed

+50
-8
lines changed

Assets/MRTK/Core/Inspectors/Utilities/InspectorUIUtility.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,11 @@ static public bool DrawScriptableFoldout<T>(SerializedProperty scriptable, strin
650650
else
651651
{
652652
bool isNestedInCurrentPrefab = false;
653-
var prefabStage = PrefabStageUtility.GetCurrentPrefabStage();
653+
#if UNITY_2021_2_OR_NEWER
654+
var prefabStage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
655+
#else
656+
var prefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
657+
#endif
654658
if (prefabStage != null)
655659
{
656660
var instancePath = AssetDatabase.GetAssetPath(scriptable.objectReferenceValue);

Assets/MRTK/Core/Utilities/BuildAndDeploy/UwpAppxBuildTools.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,11 @@ public static void AddCapabilities(IBuildInfo buildInfo, XElement rootElement =
531531
AddGazeInputCapability(rootElement);
532532
}
533533

534-
if (uwpBuildInfo.ResearchModeCapabilityEnabled && EditorUserBuildSettings.wsaSubtarget == WSASubtarget.HoloLens)
534+
if (uwpBuildInfo.ResearchModeCapabilityEnabled
535+
#if !UNITY_2021_2_OR_NEWER
536+
&& EditorUserBuildSettings.wsaSubtarget == WSASubtarget.HoloLens
537+
#endif // !UNITY_2021_2_OR_NEWER
538+
)
535539
{
536540
AddResearchModeCapability(rootElement);
537541
}

Assets/MRTK/Core/Utilities/Scenes/EditorSceneUtils.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,11 @@ public static IEnumerable<GameObject> GetRootGameObjectsInLoadedScenes()
253253
/// </summary>
254254
public static bool IsEditingPrefab()
255255
{
256+
#if UNITY_2021_2_OR_NEWER
257+
var prefabStage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
258+
#else
256259
var prefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
260+
#endif
257261
return prefabStage != null;
258262
}
259263

Assets/MRTK/SDK/Features/UX/Scripts/BoundingBox/BoundingBox.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,8 +1869,8 @@ private Bounds GetTargetBounds()
18691869

18701870
private void ExtractBoundsCorners(Transform childTransform, BoundsCalculationMethod boundsCalculationMethod)
18711871
{
1872-
KeyValuePair<Transform, Collider> colliderByTransform;
1873-
KeyValuePair<Transform, Bounds> rendererBoundsByTransform;
1872+
KeyValuePair<Transform, Collider> colliderByTransform = default;
1873+
KeyValuePair<Transform, Bounds> rendererBoundsByTransform = default;
18741874

18751875
if (boundsCalculationMethod != BoundsCalculationMethod.RendererOnly)
18761876
{

Assets/MRTK/SDK/Features/UX/Scripts/BoundsControl/BoundsControl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,8 @@ private Bounds GetTargetBounds()
902902

903903
private void ExtractBoundsCorners(Transform childTransform, BoundsCalculationMethod boundsCalculationMethod)
904904
{
905-
KeyValuePair<Transform, Collider> colliderByTransform;
906-
KeyValuePair<Transform, Bounds> rendererBoundsByTransform;
905+
KeyValuePair<Transform, Collider> colliderByTransform = default;
906+
KeyValuePair<Transform, Bounds> rendererBoundsByTransform = default;
907907

908908
if (boundsCalculationMethod != BoundsCalculationMethod.RendererOnly)
909909
{

Assets/MRTK/Tests/TestUtilities/PlayModeTestUtilities.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,10 @@ public static void EnsureInputModule()
220220
{
221221
CameraCache.Main.gameObject.AddComponent<MixedRealityInputModule>();
222222
}
223+
224+
#if !UNITY_2021_1_OR_NEWER
223225
inputModule.forceModuleActive = true;
226+
#endif // !UNITY_2021_1_OR_NEWER
224227
}
225228
}
226229

Assets/MRTK/Tools/BuildWindow/BuildDeployWindow.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ private enum BuildDeployTab
3434
DeployOptions
3535
}
3636

37+
#if UNITY_2021_2_OR_NEWER
38+
/// <summary>
39+
/// Matches the deprecated WSASubtarget.
40+
/// </summary>
41+
private enum UWPSubtarget
42+
{
43+
AnyDevice = 0,
44+
PC = 1,
45+
Mobile = 2,
46+
HoloLens = 3
47+
}
48+
#endif // UNITY_2021_2_OR_NEWER
49+
3750
#endregion Internal Types
3851

3952
#region Constants and Readonly Values
@@ -166,7 +179,13 @@ private static bool CanInstall
166179
get
167180
{
168181
bool canInstall = true;
169-
if (EditorUserBuildSettings.wsaSubtarget == WSASubtarget.HoloLens)
182+
if (
183+
#if UNITY_2021_2_OR_NEWER
184+
currentSubtarget == UWPSubtarget.HoloLens
185+
#else
186+
EditorUserBuildSettings.wsaSubtarget == WSASubtarget.HoloLens
187+
#endif // UNITY_2021_2_OR_NEWER
188+
)
170189
{
171190
canInstall = DevicePortalConnectionEnabled;
172191
}
@@ -271,6 +290,10 @@ private static bool UseRemoteTarget
271290
private static DeviceInfo lastTestConnectionTarget;
272291
private static DateTime? lastTestConnectionTime = null;
273292

293+
#if UNITY_2021_2_OR_NEWER
294+
private static UWPSubtarget currentSubtarget = UWPSubtarget.AnyDevice;
295+
#endif // UNITY_2021_2_OR_NEWER
296+
274297
#endregion Fields
275298

276299
#region Methods
@@ -380,7 +403,11 @@ private void RenderStandaloneBuildView()
380403

381404
private void RenderUnityBuildView()
382405
{
406+
#if UNITY_2021_2_OR_NEWER
407+
currentSubtarget = (UWPSubtarget)EditorGUILayout.Popup("Target Device", (int)currentSubtarget, TARGET_DEVICE_OPTIONS, GUILayout.Width(HALF_WIDTH));
408+
#else
383409
EditorUserBuildSettings.wsaSubtarget = (WSASubtarget)EditorGUILayout.Popup("Target Device", (int)EditorUserBuildSettings.wsaSubtarget, TARGET_DEVICE_OPTIONS, GUILayout.Width(HALF_WIDTH));
410+
#endif // UNITY_2021_2_OR_NEWER
384411

385412
#if !UNITY_2019_1_OR_NEWER
386413
var curScriptingBackend = PlayerSettings.GetScriptingBackend(BuildTargetGroup.WSA);

Assets/MRTK/Tools/MSBuild/Scripts/Utilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public static bool TryGetGuidForAsset(FileInfo assetPath, out Guid guid)
129129
}
130130
}
131131

132-
if (guid != null && Guid.TryParse(guidString, out guid))
132+
if (guidString != null && Guid.TryParse(guidString, out guid))
133133
{
134134
return true;
135135
}

0 commit comments

Comments
 (0)