Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [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.
  • Loading branch information
Unity Technologies committed Jul 9, 2021
1 parent a437b3c commit e5626da
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 5 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
32 changes: 32 additions & 0 deletions Editor/Metadata/XRPackageMetadataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,38 @@ orderby lm.loaderName
return retList;
}

/// <summary>
/// Return a read only list of all package metadata information currently known.
/// </summary>
/// <returns>Read only list of <see cref="IXRPackage" />.</returns>
public static IReadOnlyList<IXRPackage> GetAllPackageMetadata()
{
return s_Packages.Values.ToList().AsReadOnly();
}

/// <summary>
/// Return a read only list of all package metadata information currently known that has loaders that support the given build.
/// </summary>
/// <returns>Read only list of <see cref="IXRPackage" />.</returns>
public static IReadOnlyList<IXRPackage> GetAllPackageMetadataForBuildTarget(BuildTargetGroup buildTargetGroup)
{
HashSet<IXRPackage> ret = new HashSet<IXRPackage>();

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.
Expand Down
98 changes: 98 additions & 0 deletions Tests/Editor/MetadataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
}
}
}

}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand All @@ -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": [
{
Expand Down

0 comments on commit e5626da

Please sign in to comment.