From 8fe972a88bcfdf9f7a36bb9a64c2dd9fb361fa60 Mon Sep 17 00:00:00 2001 From: Unity Technologies <@unity> Date: Tue, 14 Feb 2023 00:00:00 +0000 Subject: [PATCH] com.unity.xr.management@4.3.3 ## [4.3.3] - 2023-02-14 ### Fixed - Settings and Loader names with numbers will now keep the numbers for the generated asset names. ## [4.3.2] - 2023-02-06 ### Fixed - Incompatibility with `com.unity.testframework.graphics` --- CHANGELOG.md | 10 ++++ Editor/EditorUtilities.cs | 9 +++- Editor/XRGeneralSettingsPerBuildTarget.cs | 57 ++++++++++++++++++++++- Tests/Editor/EditorTests.cs | 20 ++++++++ package.json | 9 ++-- 5 files changed, 99 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b59677..d9591d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ 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.3.3] - 2023-02-14 + +### Fixed +- Settings and Loader names with numbers will now keep the numbers for the generated asset names. + +## [4.3.2] - 2023-02-06 + +### Fixed +- Incompatibility with `com.unity.testframework.graphics` + ## [4.3.1] - 2022-10-14 ### Fixed diff --git a/Editor/EditorUtilities.cs b/Editor/EditorUtilities.cs index 25b57fc..79403e6 100644 --- a/Editor/EditorUtilities.cs +++ b/Editor/EditorUtilities.cs @@ -83,11 +83,16 @@ internal static string TypeNameToString(string type) if (!typeParts.Any()) return String.Empty; - string[] words = Regex.Matches(typeParts.Last(), "(^[a-z]+|[A-Z]+(?![a-z])|[A-Z][a-z]+)") + for (int i = 0; i < typeParts.Length; ++i) + { + typeParts[i] = typeParts[i].TrimStart('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); + } + + string[] words = Regex.Matches(typeParts.Last(), "[\\w\\d]+") .OfType() .Select(m => m.Value) .ToArray(); - return string.Join(" ", words); + return string.Join("", words); } internal static ScriptableObject CreateScriptableObjectInstance(string typeName, string path) diff --git a/Editor/XRGeneralSettingsPerBuildTarget.cs b/Editor/XRGeneralSettingsPerBuildTarget.cs index 0114f07..622a684 100644 --- a/Editor/XRGeneralSettingsPerBuildTarget.cs +++ b/Editor/XRGeneralSettingsPerBuildTarget.cs @@ -3,8 +3,10 @@ using System.IO; using System.Linq; using System.Runtime.CompilerServices; +using System.Threading; using UnityEngine; using UnityEngine.XR.Management; +using UnityEditor.PackageManager; using UnityEditor.XR.Management.Metadata; @@ -59,12 +61,28 @@ static XRGeneralSettingsPerBuildTarget CreateAssetSynchronized() AssetDatabase.CreateAsset(generalSettings, assetPath); AssetDatabase.SaveAssets(); } + EditorBuildSettings.AddConfigObject(XRGeneralSettings.k_SettingsKey, generalSettings, true); return generalSettings; } internal static XRGeneralSettingsPerBuildTarget GetOrCreate() - => TryFindSettingsAsset(out var generalSettings) ? generalSettings : CreateAssetSynchronized(); + { + TryFindSettingsAsset(out var generalSettings); + generalSettings = generalSettings ?? CreateAssetSynchronized(); + + var buildTargetSettings = generalSettings.SettingsForBuildTarget( + EditorUserBuildSettings.selectedBuildTargetGroup + ); + var activeLoaderCount = (buildTargetSettings?.AssignedSettings?.activeLoaders?.Count ?? 0); + if (IsInURPGraphicsTest() && activeLoaderCount == 0) + { + Debug.Log("In URP graphics test and no loaders selected. Disabling 'Initialize XR On Startup'"); + buildTargetSettings.InitManagerOnStart = false; + } + + return generalSettings; + } // Simple class to give us updates when the asset database changes. class AssetCallbacks : AssetPostprocessor @@ -135,6 +153,43 @@ internal static bool ContainsLoaderForAnyBuildTarget(string loaderTypeName) return false; } + + // Temporary workaround for a graphics issue + static bool? s_IsInURPGraphicsTest = null; + internal static bool IsInURPGraphicsTest() + { + if (!s_IsInURPGraphicsTest.HasValue) + { + s_IsInURPGraphicsTest = false; + + const string kGfxFramework = "com.unity.testing.urp"; + + var request = Client.List(offlineMode: true); + while (request.IsCompleted == false) + { + Thread.Yield(); + } + + if (request.Status != StatusCode.Success) + { + throw new InvalidOperationException( + $"Unexpected package query failure searching for {kGfxFramework}" + ); + } + + // if we find the com.unity.testing.urp package then assume we're in the URP + // graphics test. + foreach (var result in request.Result) + { + if (result.packageId.StartsWith(kGfxFramework)) + { + s_IsInURPGraphicsTest = true; + break; + } + } + } + return s_IsInURPGraphicsTest.Value; + } #endif /// diff --git a/Tests/Editor/EditorTests.cs b/Tests/Editor/EditorTests.cs index 59728fa..19df49d 100644 --- a/Tests/Editor/EditorTests.cs +++ b/Tests/Editor/EditorTests.cs @@ -82,6 +82,26 @@ public void CanCreateNewManagerSettingsForMissingBuildTargetSettings() Assert.IsNotNull(settings); Assert.IsNotNull(settings.Manager); } + + [Test] + public void VerifyValidLoaderAndSettingsTypeNames() + { + // The Expected Valid Strings must fit the C# expectations for valid type formats + Dictionary TypeNamesAndExpectedValidStrings = new Dictionary() + { + { "My.Loader", "Loader" }, + { "MyLoader2", "MyLoader2" }, + { "Prefix.My3 Loader3", "My3Loader3" }, + { "4444MyLoader", "MyLoader" }, + { "Prefix.My'; Loader_5", "MyLoader_5" }, + }; + + foreach (KeyValuePair typeAndValidation in TypeNamesAndExpectedValidStrings) + { + string result = EditorUtilities.TypeNameToString(typeAndValidation.Key); + Assert.AreEqual(typeAndValidation.Value, result); + } + } } [TestFixture(0)] // Test case where no loaders exist in the list diff --git a/package.json b/package.json index 02d291a..2b4d391 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.unity.xr.management", "displayName": "XR Plugin Management", - "version": "4.3.1", + "version": "4.3.3", "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.", @@ -23,10 +23,13 @@ "repository": { "url": "https://github.cds.internal.unity3d.com/unity/xr.sdk.management.git", "type": "git", - "revision": "0ab40a5ed855f32504cfd7f232d25f94307e1292" + "revision": "11953d1846a70bfe37146dc4655a8b2d93d32b95" + }, + "_upm": { + "changelog": "### Fixed\n- Settings and Loader names with numbers will now keep the numbers for the generated asset names." }, "upmCi": { - "footprint": "312efed7e52227e816f4ccca6c870281de4da655" + "footprint": "e47471cb7ebbf7c240bc0eccde6e675b16d3c6a9" }, "documentationUrl": "https://docs.unity3d.com/Packages/com.unity.xr.management@4.3/manual/index.html", "samples": [