Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [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`
  • Loading branch information
Unity Technologies committed Feb 14, 2023
1 parent 6c6353b commit 8fe972a
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 6 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions Editor/EditorUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Match>()
.Select(m => m.Value)
.ToArray();
return string.Join(" ", words);
return string.Join("", words);
}

internal static ScriptableObject CreateScriptableObjectInstance(string typeName, string path)
Expand Down
57 changes: 56 additions & 1 deletion Editor/XRGeneralSettingsPerBuildTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

/// <summary>
Expand Down
20 changes: 20 additions & 0 deletions Tests/Editor/EditorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> TypeNamesAndExpectedValidStrings = new Dictionary<string, string>()
{
{ "My.Loader", "Loader" },
{ "MyLoader2", "MyLoader2" },
{ "Prefix.My3 Loader3", "My3Loader3" },
{ "4444MyLoader", "MyLoader" },
{ "Prefix.My'; Loader_5", "MyLoader_5" },
};

foreach (KeyValuePair<string, string> 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
Expand Down
9 changes: 6 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.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.",
Expand All @@ -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/[email protected]/manual/index.html",
"samples": [
Expand Down

0 comments on commit 8fe972a

Please sign in to comment.