Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [3.2.16] - 2020-09-25
* Release

## [3.2.16-preview.1] - 2020-09-17

* Fix issue that was causing the UI to gray out with the "Querying Package Manager for currently installed packages..." message.
* Add documentation to clarify the differences and requirements around plug-in packages and Unity packages.
* Clarify some issues around loader and initialization.
  • Loading branch information
Unity Technologies committed Sep 25, 2020
1 parent ce31b9f commit 31f17b4
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 33 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.2.16] - 2020-09-25
* Release

## [3.2.16-preview.1] - 2020-09-17

* Fix issue that was causing the UI to gray out with the "Querying Package Manager for currently installed packages..." message.
* Add documentation to clarify the differences and requirements around plug-in packages and Unity packages.
* Clarify some issues around loader and initialization.

## [3.2.15] - 2020-09-03
* Fix issue with file being included in built package that shouldn't be there.

Expand Down
8 changes: 8 additions & 0 deletions Documentation~/Provider.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

# Package author documentation

## XR Plug-in Management packages and Unity packages

All **XR Plug-in Management** packages must also be full Unity packages. The package does not have to be registered or exist in any external repository or package server. It can live within the `Assets` folder. The only requirement is that you define the package with a `package.json` file and a unique package id.

For more information, see documentation on [Unity Packages](https://docs.unity3d.com/Manual/PackagesList.html).

## Lifecycle management

This package enables you to manage the lifecycle of XR SDK subsystems without the need for boilerplate code. The `XRManagerSettings`class provides a scriptable object that your app can use to start, stop, initialize, and deinitialize a set of subsystems defined in an `XRLoader` instance.
Expand Down Expand Up @@ -120,6 +126,8 @@ Your plug-in must provide metadata information for it to be usable by the **XR P

The system will use .Net reflection to find all types implementing the **IXRPackage** interface. It will then attempt to instantiate each one and populate the metadata store with the information provided by each instance.

You can only have one instance of **IXRPackage** within a given Unity package. The **IXRMetadata.packageId** field must return the same id as set in the package's `package.json` file.

## Example: Simple, minimal package information setup:

```
Expand Down
7 changes: 4 additions & 3 deletions Editor/Legacy/XRLegacyUninstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class XRLegacyUninstaller
"com.unity.xr.oculus.android",
"com.unity.xr.oculus.standalone",
"com.unity.xr.openvr.standalone",
"com.unity.xr.windowsmr.metro",
"com.unity.xr.windowsmr.metro",
};


Expand Down Expand Up @@ -56,6 +56,7 @@ struct LegacyPackageListRequest
public ListRequest packageListRequest;
}


private static readonly string k_PackageToRemoveQueue = "Remove Package Queue";
private static EditorWorkQueue<PackageRemovalOperation> s_PackageRemovelQueue => EditorWorkQueue<PackageRemovalOperation>.Instance;
private static bool hasPackageBeingRemoved => s_PackageRemovelQueue.HasWorkItems;
Expand All @@ -66,7 +67,7 @@ struct LegacyPackageListRequest

private static readonly string k_LocalPackageListingQueryQueue = "Local Package List";
private static EditorWorkQueue<LegacyPackageListRequest> s_PackageListQueue => EditorWorkQueue<LegacyPackageListRequest>.Instance;
private static bool hasActivePackageListQuery => EditorPrefs.HasKey(k_LocalPackageListingQueryQueue);
private static bool hasActivePackageListQuery => EditorWorkQueueBase.SessionStateHasStoredData(k_LocalPackageListingQueryQueue);


internal static bool IsPackageInstalled(string package)
Expand Down Expand Up @@ -162,7 +163,7 @@ static XRLegacyUninstaller()
if (packageIdsToRemove.Count > 0)
{
if (EditorUtility.DisplayDialog("Built in VR Detected", removeRequestText, "Ok", "Cancel"))
{
{
foreach (string packageId in packageIdsToRemove)
{
PackageRemovalRequest remreq = new PackageRemovalRequest();
Expand Down
46 changes: 32 additions & 14 deletions Editor/Metadata/XRPackageMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
using System.Linq;
using System.Text;

using UnityEditor;

using UnityEngine;
using UnityEditor.PackageManager;
using UnityEditor.PackageManager.Requests;
using UnityEngine.XR.Management;


namespace UnityEditor.XR.Management.Metadata
{
/// <summary>
Expand Down Expand Up @@ -192,14 +195,25 @@ struct LoaderAssignmentRequests
static Dictionary<string, IXRPackage> s_Packages = new Dictionary<string, IXRPackage>();
static SearchRequest s_SearchRequest = null;

internal static bool isCheckingInstallationRequirements => EditorPrefs.HasKey(k_WaitingPackmanQuery);
internal static bool isRebuildingCache => EditorPrefs.HasKey(k_RebuildCache);
internal static bool isInstallingPackages => EditorPrefs.HasKey(k_InstallingPackage);
internal static bool isUninstallingPackages => EditorPrefs.HasKey(k_UninstallingPackage);
internal static bool isAssigningLoaders => EditorPrefs.HasKey(k_AssigningPackage);
const string k_DefaultSessionStateString = "DEADBEEF";
static bool SessionStateHasStoredData(string queueName)
{
return SessionState.GetString(queueName, k_DefaultSessionStateString) != XRPackageMetadataStore.k_DefaultSessionStateString;
}

internal static bool isDoingQueueProcessing =>
isCheckingInstallationRequirements || isRebuildingCache || isInstallingPackages || isUninstallingPackages || isAssigningLoaders;
internal static bool isCheckingInstallationRequirements => XRPackageMetadataStore.SessionStateHasStoredData(k_WaitingPackmanQuery);
internal static bool isRebuildingCache => XRPackageMetadataStore.SessionStateHasStoredData(k_RebuildCache);
internal static bool isInstallingPackages => XRPackageMetadataStore.SessionStateHasStoredData(k_InstallingPackage);
internal static bool isUninstallingPackages => XRPackageMetadataStore.SessionStateHasStoredData(k_UninstallingPackage);
internal static bool isAssigningLoaders => XRPackageMetadataStore.SessionStateHasStoredData(k_AssigningPackage);

internal static bool isDoingQueueProcessing
{
get
{
return isCheckingInstallationRequirements || isRebuildingCache || isInstallingPackages || isUninstallingPackages || isAssigningLoaders;
}
}

internal struct LoaderBuildTargetQueryResult
{
Expand Down Expand Up @@ -573,9 +587,9 @@ static void AddRequestToQueue(LoaderAssignmentRequest request, string queueName)
{
LoaderAssignmentRequests reqs;

if (EditorPrefs.HasKey(queueName))
if (XRPackageMetadataStore.SessionStateHasStoredData(queueName))
{
string fromJson = EditorPrefs.GetString(queueName);
string fromJson = SessionState.GetString(queueName, k_DefaultSessionStateString);
reqs = JsonUtility.FromJson<LoaderAssignmentRequests>(fromJson);
}
else
Expand All @@ -586,26 +600,26 @@ static void AddRequestToQueue(LoaderAssignmentRequest request, string queueName)

reqs.activeRequests.Add(request);
string json = JsonUtility.ToJson(reqs);
EditorPrefs.SetString(queueName, json);
SessionState.SetString(queueName, json);

}

static void SetRequestsInQueue(LoaderAssignmentRequests reqs, string queueName)
{
string json = JsonUtility.ToJson(reqs);
EditorPrefs.SetString(queueName, json);
SessionState.SetString(queueName, json);
}

static LoaderAssignmentRequests GetAllRequestsInQueue(string queueName)
{
var reqs = new LoaderAssignmentRequests();
reqs.activeRequests = new List<LoaderAssignmentRequest>();

if (EditorPrefs.HasKey(queueName))
if (XRPackageMetadataStore.SessionStateHasStoredData(queueName))
{
string fromJson = EditorPrefs.GetString(queueName);
string fromJson = SessionState.GetString(queueName, k_DefaultSessionStateString);
reqs = JsonUtility.FromJson<LoaderAssignmentRequests>(fromJson);
EditorPrefs.DeleteKey(queueName);
SessionState.EraseString(queueName);
}

return reqs;
Expand All @@ -628,12 +642,16 @@ static void RebuildCache()
EditorApplication.update -= RebuildCache;

if (IsEditorInPlayMode())
{
return; // Use the cached data that should have been passed in the play state change.
}

LoaderAssignmentRequests reqs = GetAllRequestsInQueue(k_RebuildCache);

if (reqs.activeRequests == null || reqs.activeRequests.Count == 0)
{
return;
}

var req = reqs.activeRequests[0];
reqs.activeRequests.Remove(req);
Expand Down
27 changes: 18 additions & 9 deletions Editor/XREditorWorkQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@

namespace UnityEditor.XR.Management
{
internal class EditorWorkQueue<T>
internal class EditorWorkQueueBase
{
const string k_DefaultSessionStateString = "0BADF00D";
internal static bool SessionStateHasStoredData(string queueName)
{
return SessionState.GetString(queueName, k_DefaultSessionStateString) != EditorWorkQueueBase.k_DefaultSessionStateString;
}

}

internal class EditorWorkQueue<T> : EditorWorkQueueBase
{
[Serializable]
struct Queue
Expand All @@ -18,13 +28,12 @@ struct Queue
public List<T> workItems;
}


public string QueueName { get; set; }

private static Lazy<EditorWorkQueue<T>> s_Instance = new Lazy<EditorWorkQueue<T>>();
public static EditorWorkQueue<T> Instance => s_Instance.Value;

public bool HasWorkItems => EditorPrefs.HasKey(QueueName);
public bool HasWorkItems => EditorWorkQueueBase.SessionStateHasStoredData(QueueName);

public Action<T> ProcessItemCallback { get; set; }

Expand All @@ -38,9 +47,9 @@ public void QueueWorkItem(T workItem)
Queue queue = new Queue();
queue.workItems = new List<T>();

if (EditorPrefs.HasKey(QueueName))
if (EditorWorkQueueBase.SessionStateHasStoredData(QueueName))
{
string fromJson = EditorPrefs.GetString(QueueName);
string fromJson = SessionState.GetString(QueueName, "{}");
JsonUtility.FromJsonOverwrite(fromJson, queue);
}

Expand All @@ -51,7 +60,7 @@ public void QueueWorkItem(T workItem)

queue.workItems.Add(workItem);
string json = JsonUtility.ToJson(queue);
EditorPrefs.SetString(QueueName, json);
SessionState.SetString(QueueName, json);
StartQueue();
}

Expand Down Expand Up @@ -80,8 +89,8 @@ private static T GetNextWorkItem()
return ret;
}

string fromJson = EditorPrefs.GetString(Instance.QueueName);
EditorPrefs.DeleteKey(Instance.QueueName);
string fromJson = SessionState.GetString(Instance.QueueName, "{}");
SessionState.EraseString(Instance.QueueName);

Queue queue = JsonUtility.FromJson<Queue>(fromJson);
if (queue.workItems.Count <= 0)
Expand All @@ -95,7 +104,7 @@ private static T GetNextWorkItem()
if (queue.workItems.Count > 0)
{
string json = JsonUtility.ToJson(queue);
EditorPrefs.SetString(Instance.QueueName, json);
SessionState.SetString(Instance.QueueName, json);
}

return ret;
Expand Down
4 changes: 2 additions & 2 deletions Editor/XRSettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static SettingsProvider[] CreateAllChildSettingsProviders()
ret.Add(resProv);
}
}

return ret.ToArray();
}

Expand Down Expand Up @@ -292,7 +292,7 @@ private void DisplayXRTrackingDocumentationLink()
}
GUILayout.EndVertical();
EditorGUILayout.Space();
}
}

private void DisplayLoadOrderUi()
{
Expand Down
7 changes: 7 additions & 0 deletions Runtime/XRLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ public abstract class XRLoader : ScriptableObject
/// <summary>
/// Initialize the loader. This should initialize all subsystems to support the desired runtime setup this
/// loader represents.
///
/// This is the only method on XRLoader that Management uses to determine the active loader to use. If this
/// method returns true, Management locks this loader as the <see cref="XRManagerSettings.activeLoader"/>
/// and and stops fall through processing on the <see cref="XRManagerSettings.loaders"/> list of current loaders.
///
/// If this method returns false, <see cref="XRManagerSettings"/> continues to process the next loader
/// in the <see cref="XRManagerSettings.loaders"/> list, or fails completely when the list is exhausted.
/// </summary>
///
/// <returns>Whether or not initialization succeeded.</returns>
Expand Down
5 changes: 5 additions & 0 deletions Runtime/XRLoaderHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ protected void DestroySubsystem<T>() where T : class, ISubsystem

/// <summary>
/// Creates a subsystem given a list of descriptors and a specific subsystem id.
///
/// You should make sure to destroy any subsystem that you created so that resources
/// acquired by your subsystems are correctly cleaned up and released. This is especially important
/// if you create them during initialization, but initialization fails. If that happens,
/// you should clean up any subsystems created up to that point.
/// </summary>
///
/// <typeparam name="TDescriptor">The descriptor type being passed in.</typeparam>
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "com.unity.xr.management",
"displayName": "XR Plugin Management",
"version": "3.2.15",
"unity": "2019.3",
"unityRelease": "0f6",
"version": "3.2.16",
"unity": "2019.4",
"description": "Package to provide for simple management of XR plug-ins. Provides help and management for loading, initialization, settings, and build support for XR plug-ins.",
"keywords": [
"xr",
Expand All @@ -21,10 +20,10 @@
"repository": {
"url": "https://github.cds.internal.unity3d.com/unity/xr.sdk.management.git",
"type": "git",
"revision": "e4766bbc99071a3a42ad7c16a54936d4848452ff"
"revision": "a502c5ffdef34dcbae312ceb5ab87af156125187"
},
"upmCi": {
"footprint": "4fd2b8ab917e428e5b9770076bf6d4a1079a387f"
"footprint": "8016fc44f28c898f4a653a49ec306ea3b70918ae"
},
"samples": [
{
Expand Down

0 comments on commit 31f17b4

Please sign in to comment.