From e3ccc75d5ee2c9dfa4b49f29bcbc901f8b1cbe5f Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 13 Jul 2026 23:44:55 +0100 Subject: [PATCH] Resolve normalized Unity bundle asset names --- .../EveUnityCultMeshLiveProviderTransport.cs | 12 +++++- .../EveUnityCultMeshAssetLookupTests.cs | 42 +++++++++++++++++++ .../EveUnityCultMeshAssetLookupTests.cs.meta | 2 + .../org.gamecult.eve.unity-scene/package.json | 2 +- 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 packages/org.gamecult.eve.unity-scene/Tests/Editor/EveUnityCultMeshAssetLookupTests.cs create mode 100644 packages/org.gamecult.eve.unity-scene/Tests/Editor/EveUnityCultMeshAssetLookupTests.cs.meta diff --git a/packages/org.gamecult.eve.unity-scene/Runtime/CultMesh/EveUnityCultMeshLiveProviderTransport.cs b/packages/org.gamecult.eve.unity-scene/Runtime/CultMesh/EveUnityCultMeshLiveProviderTransport.cs index ab3ed76..385f8ab 100644 --- a/packages/org.gamecult.eve.unity-scene/Runtime/CultMesh/EveUnityCultMeshLiveProviderTransport.cs +++ b/packages/org.gamecult.eve.unity-scene/Runtime/CultMesh/EveUnityCultMeshLiveProviderTransport.cs @@ -566,14 +566,16 @@ namespace GameCult.Eve.UnityScene if (bundle == null) throw new InvalidOperationException($"Unity could not load provider asset bundle '{variant.Uri}'."); _assetBundles.Add(bundle); + var bundleAssetNames = bundle.GetAllAssetNames(); foreach (var selection in group) { - var value = bundle.LoadAsset(selection.Variant!.AssetKey); + var bundleAssetName = ResolveBundleAssetName(bundleAssetNames, selection.Variant!.AssetKey); + var value = bundleAssetName == null ? null : bundle.LoadAsset(bundleAssetName); if (value == null) throw new InvalidOperationException( $"Provider asset '{selection.Asset.AssetRef}' advertises missing Unity bundle asset " + $"'{selection.Variant.AssetKey}'. Available assets: " + - string.Join(", ", bundle.GetAllAssetNames())); + string.Join(", ", bundleAssetNames)); _nativeAssets[selection.Asset.AssetRef] = value; if (selection.Asset.Metadata.TryGetValue("presentationRole", out var role) && !string.IsNullOrWhiteSpace(role)) @@ -589,6 +591,12 @@ namespace GameCult.Eve.UnityScene CurrentAssetCatalogVersion = catalog.Version; } + private static string? ResolveBundleAssetName(IEnumerable bundleAssetNames, string advertisedAssetKey) + { + return bundleAssetNames.FirstOrDefault(assetName => + string.Equals(assetName, advertisedAssetKey, StringComparison.OrdinalIgnoreCase)); + } + private void ReadCameraPolicies(IEnumerable variants) { _renderChannelLayers.Clear(); diff --git a/packages/org.gamecult.eve.unity-scene/Tests/Editor/EveUnityCultMeshAssetLookupTests.cs b/packages/org.gamecult.eve.unity-scene/Tests/Editor/EveUnityCultMeshAssetLookupTests.cs new file mode 100644 index 0000000..17603f9 --- /dev/null +++ b/packages/org.gamecult.eve.unity-scene/Tests/Editor/EveUnityCultMeshAssetLookupTests.cs @@ -0,0 +1,42 @@ +using System.Reflection; +using GameCult.Eve.UnityScene; +using NUnit.Framework; + +namespace GameCult.Eve.UnityScene.Tests +{ + public sealed class EveUnityCultMeshAssetLookupTests + { + [Test] + public void ResolvesUnityNormalizedBundleNamesWithoutChangingLogicalAssetIdentity() + { + var method = typeof(EveUnityCultMeshLiveProviderTransport).GetMethod( + "ResolveBundleAssetName", + BindingFlags.Static | BindingFlags.NonPublic); + + Assert.That(method, Is.Not.Null); + var result = method!.Invoke(null, new object[] + { + new[] { "assets/generated/eve/thermal/death.asset" }, + "Assets/Generated/Eve/Thermal/Death.asset" + }); + + Assert.That(result, Is.EqualTo("assets/generated/eve/thermal/death.asset")); + } + + [Test] + public void RejectsBundleNamesThatDoNotMatchTheAdvertisedAsset() + { + var method = typeof(EveUnityCultMeshLiveProviderTransport).GetMethod( + "ResolveBundleAssetName", + BindingFlags.Static | BindingFlags.NonPublic); + + var result = method!.Invoke(null, new object[] + { + new[] { "assets/generated/eve/thermal/heatstroke.asset" }, + "Assets/Generated/Eve/Thermal/Death.asset" + }); + + Assert.That(result, Is.Null); + } + } +} diff --git a/packages/org.gamecult.eve.unity-scene/Tests/Editor/EveUnityCultMeshAssetLookupTests.cs.meta b/packages/org.gamecult.eve.unity-scene/Tests/Editor/EveUnityCultMeshAssetLookupTests.cs.meta new file mode 100644 index 0000000..790a2ed --- /dev/null +++ b/packages/org.gamecult.eve.unity-scene/Tests/Editor/EveUnityCultMeshAssetLookupTests.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: d746a249576c8e74696ea8add7a25731 \ No newline at end of file diff --git a/packages/org.gamecult.eve.unity-scene/package.json b/packages/org.gamecult.eve.unity-scene/package.json index 77c4245..bf99858 100644 --- a/packages/org.gamecult.eve.unity-scene/package.json +++ b/packages/org.gamecult.eve.unity-scene/package.json @@ -1,7 +1,7 @@ { "name": "org.gamecult.eve.unity-scene", "displayName": "Eve Unity Scene Lowering", - "version": "0.3.11", + "version": "0.3.12", "unity": "2021.3", "description": "Provider-agnostic Unity scene shell for gamecult.eve.surface.v1 interactive world surfaces.", "dependencies": {