From 935bfdddc332a38d476dc8fc4f1845d5ebed5349 Mon Sep 17 00:00:00 2001 From: Unity Technologies <@unity> Date: Tue, 18 May 2021 00:00:00 +0000 Subject: [PATCH] com.unity.xr.management@4.0.6 ## [4.0.6] - 2021-05-18 ### Fixes * Fix issue where XR was not being started when entering play mode if the settings UI was never displayed. * Fixed an issue where custom XR packages would not get registered when running the Unity Editor using the [-batchmode](https://docs.unity3d.com/Manual/CommandLineArguments.html) argument. ### Added * Added additional documentation explaining that manual XR Initialization should only be called from [Start](https://docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html) or later as calling it from [Awake](https://docs.unity3d.com/ScriptReference/MonoBehaviour.Awake.html) or [OnEnable](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnEnable.html) can cause issues if graphics initialization hasn't finished yet. --- CHANGELOG.md | 9 +++++++++ Documentation~/EndUser.md | 3 +-- Documentation~/com.unity.xr.management.md | 4 ++-- Editor/Metadata/XRPackageMetadataStore.cs | 1 + Editor/XRGeneralSettingsPerBuildTarget.cs | 13 +++++++------ Editor/XRPackageInitialization.cs | 10 +++++++--- package.json | 6 +++--- 7 files changed, 30 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a9a56b..6322ddb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [4.0.6] - 2021-05-18 +### Fixes +* Fix issue where XR was not being started when entering play mode if the settings UI was never displayed. +* Fixed an issue where custom XR packages would not get registered when running the Unity Editor using the [-batchmode](https://docs.unity3d.com/Manual/CommandLineArguments.html) argument. + +### Added + +* Added additional documentation explaining that manual XR Initialization should only be called from [Start](https://docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html) or later as calling it from [Awake](https://docs.unity3d.com/ScriptReference/MonoBehaviour.Awake.html) or [OnEnable](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnEnable.html) can cause issues if graphics initialization hasn't finished yet. + ## [4.0.5] - 2021-05-06 ### Fixes * Fix issue with changelog. diff --git a/Documentation~/EndUser.md b/Documentation~/EndUser.md index 2f685fd..21768c3 100644 --- a/Documentation~/EndUser.md +++ b/Documentation~/EndUser.md @@ -20,7 +20,7 @@ If you want to start XR on a per-Scene basis (for example, to start in 2D and tr |Method|Description| |---|---| -|`InitializeLoader(Async)`|Sets up the XR environment to run manually.| +|`InitializeLoader(Async)`|Sets up the XR environment to run manually. Should be called on or after [Start](https://docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html) has finished to avoid conflicts with graphics initialization sequence.| |`StartSubsystems`|Starts XR and puts your application into XR mode.| |`StopSubsystems`|Stops XR and takes your application out of XR mode. You can call `StartSubsystems` again to go back into XR mode.| |`DeinitializeLoader`|Shuts down XR and removes it entirely. You must call `InitializeLoader(Async)` before you can run XR again.| @@ -239,7 +239,6 @@ You would most likely place this script in a custom build script, but that isn't **Note:** A new loader that wasn't known at startup can't be added to the loader list at runtime, which causes the modification operation to fail. You can still modify the list during runtime, whether the app runs in Play mode or as a standalone build. - This means that you are able to do the following during runtime: - Remove loaders from the list of loaders. diff --git a/Documentation~/com.unity.xr.management.md b/Documentation~/com.unity.xr.management.md index f4ba5fe..3d19a31 100644 --- a/Documentation~/com.unity.xr.management.md +++ b/Documentation~/com.unity.xr.management.md @@ -46,11 +46,11 @@ There are two target audiences for XR Plug-in Management: the end user and the p This version of XR Plug-in Management is compatible with the following versions of the Unity Editor: -* 2019.3 and later (recommended) +* 2019.4.15f1 and later ### Known limitations -None. +Attempting to manually initialize XR using [XRManagerSettings.InitializeLoader](https://docs.unity3d.com/Packages/com.unity.xr.management@4.0/api/UnityEngine.XR.Management.XRManagerSettings.html#UnityEngine_XR_Management_XRManagerSettings_InitializeLoader) from [Awake](https://docs.unity3d.com/ScriptReference/MonoBehaviour.Awake.html) could potentially interfere with graphics initialization. If you wish to manually initialize XR then call `InitializeLoader` from [Start](https://docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html) to ensure the graphics initialization has completed. ### Package contents diff --git a/Editor/Metadata/XRPackageMetadataStore.cs b/Editor/Metadata/XRPackageMetadataStore.cs index 7df0e67..6db4e93 100644 --- a/Editor/Metadata/XRPackageMetadataStore.cs +++ b/Editor/Metadata/XRPackageMetadataStore.cs @@ -410,6 +410,7 @@ static XRPackageMetadataStore() { InitKnownPluginPackages(); + EditorApplication.playModeStateChanged -= PlayModeStateChanged; EditorApplication.playModeStateChanged += PlayModeStateChanged; if (IsEditorInPlayMode()) diff --git a/Editor/XRGeneralSettingsPerBuildTarget.cs b/Editor/XRGeneralSettingsPerBuildTarget.cs index e974eb1..af7dccb 100644 --- a/Editor/XRGeneralSettingsPerBuildTarget.cs +++ b/Editor/XRGeneralSettingsPerBuildTarget.cs @@ -24,6 +24,13 @@ public class XRGeneralSettingsPerBuildTarget : ScriptableObject, ISerializationC #if UNITY_EDITOR + + static XRGeneralSettingsPerBuildTarget() + { + EditorApplication.playModeStateChanged -= PlayModeStateChanged; + EditorApplication.playModeStateChanged += PlayModeStateChanged; + } + // Simple class to give us updates when the asset database changes. class AssetCallbacks : AssetPostprocessor { @@ -49,14 +56,8 @@ static void BeginUpgradeSettings() } } - private void OnDisable() - { - EditorApplication.playModeStateChanged -= PlayModeStateChanged; - } - void OnEnable() { - EditorApplication.playModeStateChanged += PlayModeStateChanged; foreach (var setting in Settings.Values) { var assignedSettings = setting.AssignedSettings; diff --git a/Editor/XRPackageInitialization.cs b/Editor/XRPackageInitialization.cs index 0c2154f..a92910f 100644 --- a/Editor/XRPackageInitialization.cs +++ b/Editor/XRPackageInitialization.cs @@ -41,13 +41,17 @@ class XRPackageInitializationBootstrap { static XRPackageInitializationBootstrap() { - if (!EditorApplication.isPlayingOrWillChangePlaymode) + if (!EditorApplication.isPlayingOrWillChangePlaymode && !Application.isBatchMode) { EditorApplication.update += BeginPackageInitialization; } + else + { + BeginPackageInitialization(); + } + EditorApplication.playModeStateChanged -= PlayModeStateChanged; EditorApplication.playModeStateChanged += PlayModeStateChanged; - } private static void PlayModeStateChanged(PlayModeStateChange state) @@ -126,7 +130,7 @@ static bool InitializePackageFromMetadata(IXRPackage package, IXRPackageMetadata ret = ret && InitializeSettingsFromMetadata(package, packageMetadata.packageName, packageMetadata.settingsType); return ret; } - + static bool InitializeLoaderFromMetadata(string packageName, List loaderMetadatas) { if (String.IsNullOrEmpty(packageName)) diff --git a/package.json b/package.json index 66737a0..3137b98 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.unity.xr.management", "displayName": "XR Plugin Management", - "version": "4.0.5", + "version": "4.0.6", "unity": "2019.4", "unityRelease": "15f1", "description": "Package that provides simple management of XR plug-ins. Manages and offers help with loading, initialization, settings, and build support for XR plug-ins.", @@ -24,10 +24,10 @@ "repository": { "url": "https://github.cds.internal.unity3d.com/unity/xr.sdk.management.git", "type": "git", - "revision": "59665b284b3b388bea2dcb98a8f3e4748694f3e6" + "revision": "abdf3fbaa4f4cde7145c508df7d60d9ca6f4ecc3" }, "upmCi": { - "footprint": "a881f9784f5415835b3f235181661038d23b73e2" + "footprint": "d9cbbe0a2f9ce6a9d9d4d44e4c7be43dd0fd8783" }, "samples": [ {