Remove daemon render Resources fallback
This commit is contained in:
parent
1b81fe9ddf
commit
3cfa6d3506
3 changed files with 42 additions and 20 deletions
|
|
@ -247,7 +247,8 @@ public sealed class AetheriaDaemonIndirectRenderer : MonoBehaviour
|
|||
return true;
|
||||
}
|
||||
|
||||
return assetCatalog.TryResolveMesh(renderGroup?.MeshKey, out mesh);
|
||||
mesh = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool TryResolveMaterial(AetheriaRuntimeDaemonRenderGroupDocument renderGroup, out Material material)
|
||||
|
|
@ -259,6 +260,7 @@ public sealed class AetheriaDaemonIndirectRenderer : MonoBehaviour
|
|||
return true;
|
||||
}
|
||||
|
||||
return assetCatalog.TryResolveMaterial(renderGroup?.MaterialKey, out material);
|
||||
material = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ public sealed class AetheriaDaemonRenderAssetCatalog : ScriptableObject
|
|||
[SerializeField]
|
||||
private MaterialEntry[] materials = Array.Empty<MaterialEntry>();
|
||||
|
||||
[SerializeField]
|
||||
private TextureEntry[] textures = Array.Empty<TextureEntry>();
|
||||
|
||||
public bool TryResolveMesh(string key, out Mesh mesh)
|
||||
{
|
||||
mesh = null;
|
||||
|
|
@ -30,8 +33,7 @@ public sealed class AetheriaDaemonRenderAssetCatalog : ScriptableObject
|
|||
}
|
||||
}
|
||||
|
||||
mesh = Resources.Load<Mesh>(NormalizeResourceKey(key));
|
||||
return mesh != null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryResolveMesh(AetheriaRuntimeAssetRef asset, out Mesh mesh)
|
||||
|
|
@ -56,8 +58,7 @@ public sealed class AetheriaDaemonRenderAssetCatalog : ScriptableObject
|
|||
}
|
||||
}
|
||||
|
||||
material = Resources.Load<Material>(NormalizeResourceKey(key));
|
||||
return material != null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryResolveMaterial(AetheriaRuntimeAssetRef asset, out Material material)
|
||||
|
|
@ -70,21 +71,20 @@ public sealed class AetheriaDaemonRenderAssetCatalog : ScriptableObject
|
|||
texture = null;
|
||||
var key = ResolveLocalKey(asset);
|
||||
if (string.IsNullOrWhiteSpace(key))
|
||||
return false;
|
||||
|
||||
texture = Resources.Load<Texture2D>(NormalizeResourceKey(key));
|
||||
return texture != null;
|
||||
}
|
||||
|
||||
private static string NormalizeResourceKey(string key)
|
||||
{
|
||||
const string resourcesPrefix = "resources://";
|
||||
if (key.StartsWith(resourcesPrefix, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return key.Substring(resourcesPrefix.Length);
|
||||
return false;
|
||||
}
|
||||
|
||||
return key;
|
||||
for (var i = 0; i < textures.Length; i++)
|
||||
{
|
||||
if (string.Equals(textures[i].Key, key, StringComparison.Ordinal))
|
||||
{
|
||||
texture = textures[i].Texture;
|
||||
return texture != null;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static string ResolveLocalKey(AetheriaRuntimeAssetRef asset)
|
||||
|
|
@ -92,10 +92,7 @@ public sealed class AetheriaDaemonRenderAssetCatalog : ScriptableObject
|
|||
if (asset == null)
|
||||
return "";
|
||||
|
||||
if (string.Equals(asset.Transport, AetheriaRuntimeAssetTransports.Resources, StringComparison.OrdinalIgnoreCase))
|
||||
return asset.Uri;
|
||||
|
||||
return string.IsNullOrWhiteSpace(asset.Uri) ? asset.AssetKey : asset.Uri;
|
||||
return string.IsNullOrWhiteSpace(asset.AssetKey) ? asset.Uri ?? "" : asset.AssetKey;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
|
@ -111,4 +108,11 @@ public sealed class AetheriaDaemonRenderAssetCatalog : ScriptableObject
|
|||
public string Key;
|
||||
public Material Material;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
private struct TextureEntry
|
||||
{
|
||||
public string Key;
|
||||
public Texture2D Texture;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue