Resolve normalized Unity bundle asset names
This commit is contained in:
parent
f864bdea41
commit
e3ccc75d5e
4 changed files with 55 additions and 3 deletions
|
|
@ -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<string> bundleAssetNames, string advertisedAssetKey)
|
||||
{
|
||||
return bundleAssetNames.FirstOrDefault(assetName =>
|
||||
string.Equals(assetName, advertisedAssetKey, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
private void ReadCameraPolicies(IEnumerable<EveAssetVariant> variants)
|
||||
{
|
||||
_renderChannelLayers.Clear();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d746a249576c8e74696ea8add7a25731
|
||||
|
|
@ -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": {
|
||||
|
|
|
|||
Reference in a new issue