Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [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.
  • Loading branch information
Unity Technologies committed Oct 28, 2019
1 parent 9c08282 commit 54fada6
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 71 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Editor/InputHelpersConfigurationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
20 changes: 13 additions & 7 deletions Editor/XRGeneralSettingsPerBuildTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -82,7 +85,7 @@ static void PlayModeStateChanged(PlayModeStateChange state)
if (instance == null || !instance.InitManagerOnStart)
return;

instance.InternalPlayModeStateChanged(state);
instance.InternalPauseStateChanged(state);
}
#endif

Expand All @@ -92,6 +95,9 @@ static void PlayModeStateChanged(PlayModeStateChange state)
/// <param name="settings">An instance of <see cref="XRGeneralSettings"> to assign for the given key.</param>
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;
}

Expand Down
41 changes: 10 additions & 31 deletions Editor/XRPackageInitialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
Expand All @@ -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;
Expand Down
63 changes: 34 additions & 29 deletions Runtime/XRGeneralSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,22 @@ public XRManagerSettings Manager

private XRManagerSettings m_XRManager = null;

private bool m_ProviderIntialized = false;
private bool m_ProviderStarted = false;

/// <summary>The current settings instance.</summary>
public static XRGeneralSettings Instance
{
get
{
return s_RuntimeSettingsInstance;
}
#if UNITY_EDITOR
set
{
s_RuntimeSettingsInstance = value;
}
#endif
}

/// <summary>The current active manager used to manage XR lifetime.</summary>
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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;
Expand All @@ -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()
Expand All @@ -197,13 +198,15 @@ private void InitXRSDK()
m_XRManager.automaticLoading = false;
m_XRManager.automaticRunning = false;
m_XRManager.InitializeLoaderSync();
m_ProviderIntialized = true;
}

private void StartXRSDK()
{
if (m_XRManager != null && m_XRManager.activeLoader != null)
{
m_XRManager.StartSubsystems();
m_ProviderStarted = true;
}
}

Expand All @@ -212,6 +215,7 @@ private void StopXRSDK()
if (m_XRManager != null && m_XRManager.activeLoader != null)
{
m_XRManager.StopSubsystems();
m_ProviderStarted = false;
}
}

Expand All @@ -221,6 +225,7 @@ private void DeInitXRSDK()
{
m_XRManager.DeinitializeLoader();
m_XRManager = null;
m_ProviderIntialized = false;
}
}

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -18,7 +19,7 @@
"repository": {
"type": "git",
"url": "[email protected]:unity/xr.sdk.management.git",
"revision": "d7fb91c38136b243b79e3fde61895e22ca5004b3"
"revision": "3ad70396a3b7ef6b93f504f68978954c8a6022d1"
},
"samples": [
{
Expand Down

0 comments on commit 54fada6

Please sign in to comment.