From e5626dadc32ea54afabb29eb4719d7f8f771850e Mon Sep 17 00:00:00 2001
From: Unity Technologies <@unity>
Date: Fri, 9 Jul 2021 00:00:00 +0000
Subject: [PATCH] com.unity.xr.management@4.1.0-pre.1 ## [4.1.0-pre.1] -
2021-07-09 ### Fixes * Fix
[1343655](https://issuetracker.unity3d.com/product/unity/issues/guid/1343655/)
by adding an API for getting all package metadata so that users can use the
correct information when dealing with package metadata store.
---
CHANGELOG.md | 9 ++-
Editor/Metadata/XRPackageMetadataStore.cs | 32 ++++++++
Tests/Editor/MetadataTests.cs | 98 +++++++++++++++++++++++
package.json | 6 +-
4 files changed, 140 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ac037e9..ba5b8b8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,12 +4,17 @@ 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.7] - 2021-07-01
-
+## [4.1.0-pre.1] - 2021-07-09
### Fixes
+* Fix [1343655](https://issuetracker.unity3d.com/product/unity/issues/guid/1343655/) by adding an API for getting all package metadata so that users can use the correct information when dealing with package metadata store.
+## [4.0.7] - 2021-07-01
* Fixed an issue where object from deleted asset got reused, when upgrading setting asset
+## [4.1.0-exp.1] - 2021-06-29
+## Updates
+Initial test release to Candidates
+
## [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.
diff --git a/Editor/Metadata/XRPackageMetadataStore.cs b/Editor/Metadata/XRPackageMetadataStore.cs
index 6db4e93..8e98822 100644
--- a/Editor/Metadata/XRPackageMetadataStore.cs
+++ b/Editor/Metadata/XRPackageMetadataStore.cs
@@ -191,6 +191,38 @@ orderby lm.loaderName
return retList;
}
+ ///
+ /// Return a read only list of all package metadata information currently known.
+ ///
+ /// Read only list of .
+ public static IReadOnlyList GetAllPackageMetadata()
+ {
+ return s_Packages.Values.ToList().AsReadOnly();
+ }
+
+ ///
+ /// Return a read only list of all package metadata information currently known that has loaders that support the given build.
+ ///
+ /// Read only list of .
+ public static IReadOnlyList GetAllPackageMetadataForBuildTarget(BuildTargetGroup buildTargetGroup)
+ {
+ HashSet ret = new HashSet();
+
+ foreach (var p in s_Packages.Values)
+ {
+ foreach (var lm in p.metadata.loaderMetadata)
+ {
+ if (lm.supportedBuildTargets.Contains(buildTargetGroup))
+ {
+ ret.Add(p);
+ break;
+ }
+ }
+ }
+
+ return ret.ToList().AsReadOnly();
+ }
+
internal static IXRPackageMetadata GetMetadataForPackage(string packageId)
{
return s_Packages.Values.
diff --git a/Tests/Editor/MetadataTests.cs b/Tests/Editor/MetadataTests.cs
index bd43493..88fa99c 100644
--- a/Tests/Editor/MetadataTests.cs
+++ b/Tests/Editor/MetadataTests.cs
@@ -100,5 +100,103 @@ public IEnumerator AccessSettings()
Assert.IsNotNull(instance);
}
+ [Test, Sequential]
+ public void FilteringAllMetadataByBuildTargetGroup(
+ [Values(BuildTargetGroup.Standalone, BuildTargetGroup.Android, BuildTargetGroup.Unknown, BuildTargetGroup.WebGL)]BuildTargetGroup buildTargetGroup,
+ [Values("Test Loader One", "Test Loader Two", "Test Loader Three", "")]string expectedType)
+ {
+ var packages = XRPackageMetadataStore.GetAllPackageMetadataForBuildTarget(buildTargetGroup);
+ Assert.IsTrue((packages.Count > 0 && !String.IsNullOrEmpty(expectedType)) ||
+ (packages.Count <= 0 && String.IsNullOrEmpty(expectedType)));
+
+ if (!String.IsNullOrEmpty(expectedType))
+ {
+ var loaderNames = from lm in (from p in packages select p.metadata.loaderMetadata)
+ from l in lm
+ where String.Compare(l.loaderName, expectedType, false) == 0
+ select l.loaderName;
+ Assert.IsTrue(loaderNames.Any());
+ Assert.IsTrue(loaderNames.Count() == 1);
+ }
+ }
+
+ [Test, Sequential]
+ public void FilteringAllMetadataByBuildTargetGroupReturnsSameSet(
+ [Values(BuildTargetGroup.Standalone, BuildTargetGroup.Android, BuildTargetGroup.Unknown, BuildTargetGroup.WebGL)]BuildTargetGroup buildTargetGroup,
+ [Values("Test Loader One", "Test Loader Two", "Test Loader Three", "")]string expectedType)
+ {
+ var loaders = XRPackageMetadataStore.GetLoadersForBuildTarget(buildTargetGroup);
+ Assert.IsTrue((loaders.Count > 0 && !String.IsNullOrEmpty(expectedType)) ||
+ (loaders.Count <= 0 && String.IsNullOrEmpty(expectedType)));
+
+ var packages = XRPackageMetadataStore.GetAllPackageMetadataForBuildTarget(buildTargetGroup);
+ Assert.IsTrue((packages.Count > 0 && !String.IsNullOrEmpty(expectedType)) ||
+ (packages.Count <= 0 && String.IsNullOrEmpty(expectedType)));
+
+ if (!String.IsNullOrEmpty(expectedType))
+ {
+ var loaderNames = from lm in loaders where String.Compare(lm.loaderName, expectedType, false) == 0 select lm.loaderName;
+ Assert.IsTrue(loaderNames.Any());
+ Assert.IsTrue(loaderNames.Count() == 1);
+
+ var packageLoaderNames = from lm in (from p in packages select p.metadata.loaderMetadata)
+ from l in lm
+ where String.Compare(l.loaderName, expectedType, false) == 0
+ select l.loaderName;
+ Assert.IsTrue(packageLoaderNames.Any());
+ Assert.IsTrue(packageLoaderNames.Count() == 1);
+
+ Assert.AreEqual(loaderNames.First(), packageLoaderNames.First());
+ }
+ }
+
+ [Test]
+ public void CanGetAllPackageMetadata()
+ {
+ var packages = XRPackageMetadataStore.GetAllPackageMetadata();
+
+ foreach (var package in packages)
+ {
+
+ if (String.CompareOrdinal("Test Package", package.metadata.packageName) != 0)
+ continue;
+
+ Assert.AreEqual("Test Package", package.metadata.packageName);
+ Assert.AreEqual("com.unity.xr.testpackage", package.metadata.packageId);
+ Assert.AreEqual(typeof(TestSettings).FullName, package.metadata.settingsType);
+
+ Assert.AreEqual(3, package.metadata.loaderMetadata.Count);
+ foreach (var lm in package.metadata.loaderMetadata)
+ {
+ switch (lm.loaderName)
+ {
+ case "Test Loader One":
+ Assert.AreEqual(typeof(TestLoaderOne).FullName, lm.loaderType);
+ Assert.IsTrue(lm.supportedBuildTargets.Count == 2);
+ Assert.IsTrue(lm.supportedBuildTargets.Contains(BuildTargetGroup.Standalone));
+ Assert.IsTrue(lm.supportedBuildTargets.Contains(BuildTargetGroup.WSA));
+ break;
+
+ case "Test Loader Two":
+ Assert.AreEqual(typeof(TestLoaderTwo).FullName, lm.loaderType);
+ Assert.IsTrue(lm.supportedBuildTargets.Count == 3);
+ Assert.IsTrue(lm.supportedBuildTargets.Contains(BuildTargetGroup.Android));
+ Assert.IsTrue(lm.supportedBuildTargets.Contains(BuildTargetGroup.iOS));
+ Assert.IsTrue(lm.supportedBuildTargets.Contains(BuildTargetGroup.Lumin));
+ break;
+
+ case "Test Loader Three":
+ Assert.AreEqual(typeof(TestLoaderThree).FullName, lm.loaderType);
+ Assert.IsTrue(lm.supportedBuildTargets.Count == 1);
+ Assert.IsTrue(lm.supportedBuildTargets.Contains(BuildTargetGroup.Unknown));
+ break;
+
+ default:
+ throw new Exception($"Found unknown test loader {lm.loaderName}");
+ }
+ }
+ }
+ }
+
}
}
diff --git a/package.json b/package.json
index 2782ccb..792ea59 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "com.unity.xr.management",
"displayName": "XR Plugin Management",
- "version": "4.0.7",
+ "version": "4.1.0-pre.1",
"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": "3348f9eabec889376a8c4615b6df73cd5a76b1cc"
+ "revision": "9cab3b65f780e760a46b77e66f5c8030e3f3861e"
},
"upmCi": {
- "footprint": "16596b51b3b00a63d8388135ed5180c12d0613d4"
+ "footprint": "2e960d8e2b79d4147f4e7048fe7c69b30eee63e7"
},
"samples": [
{