diff --git a/CHANGELOG.md b/CHANGELOG.md index a0e511f..9a39a4f 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). +## [3.0.4-preview.3] - 2019-10-29 +* Update minimum compatible Editor version to 2019.3.0b9 +* Fixes an issue where subsystems could not be initialized before awake in the editor +* Fixes an issue where subsystems were not re-started after a pause in the editor +* Removes dialog boxes for creating Loaders and initializing settings. + +## [3.0.4-preview.2] - 2019-10-23 +* Modifies wording of LIH inclusion page from "required" to recommended. + ## [3.0.4-preview.1] - 2019-09-20 * Public API InitializeLoaderAsync was erroneously made internal. Move back to being publicly accessible. * Fix editor application perf issue due to not unhooking update callback. diff --git a/Editor/InputHelpersConfigurationProvider.cs b/Editor/InputHelpersConfigurationProvider.cs index 677b7a0..f38ca09 100644 --- a/Editor/InputHelpersConfigurationProvider.cs +++ b/Editor/InputHelpersConfigurationProvider.cs @@ -12,7 +12,7 @@ namespace UnityEditor.XR.Management { internal class InputHelpersConfigurationProvider : SettingsProvider { - const string s_LIHReasonText = "It is required that the Tracked Pose Driver be used to enable a game camera to follow an XR device. The Tracked Pose Driver component is part of the com.unity.xr.legacyinputhelpers package. This package is not currently installed. Please press the button below to install the package."; + const string s_LIHReasonText = "It is recommended that the Tracked Pose Driver be used to enable a game camera to follow an XR device. The Tracked Pose Driver component is part of the com.unity.xr.legacyinputhelpers package. This package is not currently installed. Please press the button below to install the package."; static GUIContent s_InstallLIHLabel = new GUIContent("Install Legacy Input Helpers Package"); diff --git a/Editor/XRGeneralSettingsPerBuildTarget.cs b/Editor/XRGeneralSettingsPerBuildTarget.cs index 9e7c6d2..bfa00c4 100644 --- a/Editor/XRGeneralSettingsPerBuildTarget.cs +++ b/Editor/XRGeneralSettingsPerBuildTarget.cs @@ -53,10 +53,15 @@ static void BeginUpgradeSettings() static XRGeneralSettingsPerBuildTarget() { EditorApplication.playModeStateChanged += PlayModeStateChanged; + EditorApplication.pauseStateChanged += PauseStateChange; } - [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)] - static void AttemptInitializeXRSDKBeforePlayModeStarted() + void OnEnable() + { + XRGeneralSettings.Instance = XRGeneralSettingsForBuildTarget(BuildTargetGroup.Standalone); + } + + static void PlayModeStateChanged(PlayModeStateChange state) { XRGeneralSettingsPerBuildTarget buildTargetSettings = null; EditorBuildSettings.TryGetConfigObject(XRGeneralSettings.k_SettingsKey, out buildTargetSettings); @@ -67,11 +72,9 @@ static void AttemptInitializeXRSDKBeforePlayModeStarted() if (instance == null || !instance.InitManagerOnStart) return; - instance.InternalPlayModeStateChanged(PlayModeStateChange.EnteredPlayMode); + instance.InternalPlayModeStateChanged(state); } - - - static void PlayModeStateChanged(PlayModeStateChange state) + static void PauseStateChange(PauseState state) { XRGeneralSettingsPerBuildTarget buildTargetSettings = null; EditorBuildSettings.TryGetConfigObject(XRGeneralSettings.k_SettingsKey, out buildTargetSettings); @@ -82,7 +85,7 @@ static void PlayModeStateChanged(PlayModeStateChange state) if (instance == null || !instance.InitManagerOnStart) return; - instance.InternalPlayModeStateChanged(state); + instance.InternalPauseStateChanged(state); } #endif @@ -92,6 +95,9 @@ static void PlayModeStateChanged(PlayModeStateChange state) /// An instance of to assign for the given key. public void SetSettingsForBuildTarget(BuildTargetGroup targetGroup, XRGeneralSettings settings) { + // Ensures the editor's "runtime instance" is the most current for standalone settings + if (targetGroup == BuildTargetGroup.Standalone) + XRGeneralSettings.Instance = settings; Settings[targetGroup] = settings; } diff --git a/Editor/XRPackageInitialization.cs b/Editor/XRPackageInitialization.cs index 80f15b3..deff152 100644 --- a/Editor/XRPackageInitialization.cs +++ b/Editor/XRPackageInitialization.cs @@ -159,7 +159,6 @@ static ScriptableObject CreateScriptableObjectInstance(string packageName, strin string fileName = String.Format("{0}.asset", EditorUtilities.TypeNameToString(typeName)); string targetPath = Path.Combine(path, fileName); AssetDatabase.CreateAsset(obj, targetPath); - Debug.LogFormat("{0} package initialization created default {1} instance at path {2}", packageName, instanceType.ToLower(), path); return obj; } } @@ -169,24 +168,14 @@ static ScriptableObject CreateScriptableObjectInstance(string packageName, strin static bool InitializeLoaderInstance(XRPackageInitializationBase packageInit) { bool ret = EditorUtilities.AssetDatabaseHasInstanceOfType(packageInit.LoaderTypeName); - if (Application.isBatchMode) - return true; if (!ret) { - ret = EditorUtility.DisplayDialog( - String.Format("{0} Package Initialization", packageInit.PackageName), - String.Format("Before using the {0} package you need to create an instance of the {0} Loader. Would you like to do that now?", packageInit.PackageName), - "Create Loader", - "Cancel"); - if (ret) - { - var obj = CreateScriptableObjectInstance(packageInit.PackageName, - packageInit.LoaderFullTypeName, - "Loader", - EditorUtilities.GetAssetPathForComponents(EditorUtilities.s_DefaultLoaderPath)); - ret = (obj != null); - } + var obj = CreateScriptableObjectInstance(packageInit.PackageName, + packageInit.LoaderFullTypeName, + "Loader", + EditorUtilities.GetAssetPathForComponents(EditorUtilities.s_DefaultLoaderPath)); + ret = (obj != null); } return ret; @@ -195,24 +184,14 @@ static bool InitializeLoaderInstance(XRPackageInitializationBase packageInit) static bool InitializeSettingsInstance(XRPackageInitializationBase packageInit) { bool ret = EditorUtilities.AssetDatabaseHasInstanceOfType(packageInit.SettingsTypeName); - if (Application.isBatchMode) - return true; if (!ret) { - ret = EditorUtility.DisplayDialog( - String.Format("{0} Package Initialization", packageInit.PackageName), - String.Format("Before using the {0} package you should create an instance of {0} Settings to provide for custom configuration. Would you like to do that now?", packageInit.PackageName), - "Create Settings", - "Cancel"); - if (ret) - { - var obj = CreateScriptableObjectInstance(packageInit.PackageName, - packageInit.SettingsFullTypeName, - "Settings", - EditorUtilities.GetAssetPathForComponents(EditorUtilities.s_DefaultSettingsPath)); - ret = packageInit.PopulateSettingsOnInitialization(obj); - } + var obj = CreateScriptableObjectInstance(packageInit.PackageName, + packageInit.SettingsFullTypeName, + "Settings", + EditorUtilities.GetAssetPathForComponents(EditorUtilities.s_DefaultSettingsPath)); + ret = packageInit.PopulateSettingsOnInitialization(obj); } return ret; diff --git a/Runtime/XRGeneralSettings.cs b/Runtime/XRGeneralSettings.cs index c6f5c5b..83570fc 100644 --- a/Runtime/XRGeneralSettings.cs +++ b/Runtime/XRGeneralSettings.cs @@ -33,6 +33,9 @@ public XRManagerSettings Manager private XRManagerSettings m_XRManager = null; + private bool m_ProviderIntialized = false; + private bool m_ProviderStarted = false; + /// The current settings instance. public static XRGeneralSettings Instance { @@ -40,6 +43,12 @@ public static XRGeneralSettings Instance { return s_RuntimeSettingsInstance; } +#if UNITY_EDITOR + set + { + s_RuntimeSettingsInstance = value; + } +#endif } /// The current active manager used to manage XR lifetime. @@ -84,32 +93,33 @@ void Awake() #endif #if UNITY_EDITOR - bool m_IsPlaying = false; - void EnterPlayMode() + void Pause() { - if (!m_IsPlaying) + if (m_ProviderIntialized && m_ProviderStarted) { - if (s_RuntimeSettingsInstance == null) - s_RuntimeSettingsInstance = this; + StopXRSDK(); + } + } - InitXRSDK(); + void Unpause() + { + if (m_ProviderIntialized && !m_ProviderStarted) + { StartXRSDK(); - m_IsPlaying = true; } } - void ExitPlayMode() + public void InternalPauseStateChanged(PauseState state) { - if (m_IsPlaying) + switch (state) { - m_IsPlaying = false; - StopXRSDK(); - DeInitXRSDK(); - - if (s_RuntimeSettingsInstance != null) - s_RuntimeSettingsInstance = null; - + case PauseState.Paused: + Pause(); + break; + case PauseState.Unpaused: + Unpause(); + break; } } @@ -118,20 +128,16 @@ public void InternalPlayModeStateChanged(PlayModeStateChange state) { switch (state) { - case PlayModeStateChange.ExitingEditMode: - break; - case PlayModeStateChange.EnteredPlayMode: - EnterPlayMode(); - break; case PlayModeStateChange.ExitingPlayMode: - ExitPlayMode(); + Quit(); break; + case PlayModeStateChange.ExitingEditMode: + case PlayModeStateChange.EnteredPlayMode: case PlayModeStateChange.EnteredEditMode: break; } } -#else - +#endif static void Quit() { XRGeneralSettings instance = XRGeneralSettings.Instance; @@ -156,30 +162,25 @@ void OnDestroy() { DeInitXRSDK(); } -#endif [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)] internal static void AttemptInitializeXRSDKOnLoad() { -#if !UNITY_EDITOR XRGeneralSettings instance = XRGeneralSettings.Instance; if (instance == null || !instance.InitManagerOnStart) return; instance.InitXRSDK(); -#endif } [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)] internal static void AttemptStartXRSDKOnBeforeSplashScreen() { -#if !UNITY_EDITOR XRGeneralSettings instance = XRGeneralSettings.Instance; if (instance == null || !instance.InitManagerOnStart) return; instance.StartXRSDK(); -#endif } private void InitXRSDK() @@ -197,6 +198,7 @@ private void InitXRSDK() m_XRManager.automaticLoading = false; m_XRManager.automaticRunning = false; m_XRManager.InitializeLoaderSync(); + m_ProviderIntialized = true; } private void StartXRSDK() @@ -204,6 +206,7 @@ private void StartXRSDK() if (m_XRManager != null && m_XRManager.activeLoader != null) { m_XRManager.StartSubsystems(); + m_ProviderStarted = true; } } @@ -212,6 +215,7 @@ private void StopXRSDK() if (m_XRManager != null && m_XRManager.activeLoader != null) { m_XRManager.StopSubsystems(); + m_ProviderStarted = false; } } @@ -221,6 +225,7 @@ private void DeInitXRSDK() { m_XRManager.DeinitializeLoader(); m_XRManager = null; + m_ProviderIntialized = false; } } diff --git a/package.json b/package.json index 681f75f..ca74de0 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,9 @@ { "name": "com.unity.xr.management", "displayName": "XR Management", - "version": "3.0.4-preview.1", - "unity": "2019.2", + "version": "3.0.4-preview.3", + "unity": "2019.3", + "unityRelease": "0b9", "description": "Package to provide for simple management of XR plugins. Provides help and management for loading, initialization, settings, and build support for XR plugins.", "keywords": [ "xr", @@ -18,7 +19,7 @@ "repository": { "type": "git", "url": "git@github.cds.internal.unity3d.com:unity/xr.sdk.management.git", - "revision": "d7fb91c38136b243b79e3fde61895e22ca5004b3" + "revision": "3ad70396a3b7ef6b93f504f68978954c8a6022d1" }, "samples": [ {