public sealed class AssetManagerTurns addresses into loaded assets, once each, and unloads them when nobody wants them.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Three things joined: the catalog says what an address is and what it needs, the bundle source says where those bytes are, and the object database turns bytes into objects. What this adds is the part none of them can do alone — knowing that two callers asking for the same texture should get one texture, and that it goes away when both are done.
Dependencies are claimed by their dependents. Loading a material claims the texture it points at, so the texture survives exactly as long as some material needs it. That is the property that makes sharing safe, and it is why a handle remembers the whole closure it acquired rather than just the address that was asked for.
Loading is deduplicated by the task, not by the result. Two callers asking for the same address while it is still in flight get the same Task`1, so the work happens once even though neither of them waited for the other. Checking "is it loaded yet" instead would start it twice under exactly the concurrency the check exists for.
A dependency is loaded before the thing that needs it, and shared with it. The closure comes back dependency-first, each address is deserialised in that order, and a resolver is in force while it happens — so a material's reference to a texture lands on the very object the manager already loaded rather than on a second copy of it. That is what makes two materials sharing a texture mean one texture.
Fields and properties (3)
public ContentCatalog CatalogWhat addresses mean.
public IBundleSource BundlesWhere bundles come from.
public int LoadedCountHow many addresses are currently held.
Methods (17)
public AssetManager(ContentCatalog catalog, IBundleSource bundles, ObjectDatabase? database = null)Sets up a manager.
public AssetHandle<T> LoadAsync<T>(string address, CancellationToken cancellationToken = default(CancellationToken)) where T : classStarts loading an asset and everything it needs.
public AssetHandle<T> Load<T>(string address, CancellationToken cancellationToken = default(CancellationToken)) where T : classLoads an asset, blocking until it is there.
public AssetHandle<T> LoadAsync<T>(AssetReference reference, CancellationToken cancellationToken = default(CancellationToken)) where T : classStarts loading whatever a vx: reference points at.
public AssetHandle<T> Load<T>(AssetReference reference, CancellationToken cancellationToken = default(CancellationToken)) where T : classLoads whatever a vx: reference points at, blocking until it is there.
public string AddressOf(AssetReference reference)What address a reference resolves to.
public ImmutableArray<AssetHandle<T>> LoadByLabelAsync<T>(string label, CancellationToken cancellationToken = default(CancellationToken)) where T : classLoads everything carrying a label.
public ImmutableArray<AssetHandle<T>> LoadMatchingAsync<T>(string pattern, CancellationToken cancellationToken = default(CancellationToken)) where T : classLoads everything matching a glob.
public AssetScope Scope()Opens a scope that releases everything loaded through it.
public ValueTask<Stream> OpenAsync(string address, CancellationToken cancellationToken = default(CancellationToken))Opens an address's bytes as a stream, without deserialising anything.
public Stream Open(string address, CancellationToken cancellationToken = default(CancellationToken))Opens an address's bytes, blocking until they are there.
public bool CanOpen(string address)Whether an address is one this manager could open right now.
public long DownloadSize(params IEnumerable<string> addresses)How many bytes have to be downloaded before some addresses can load.
public Task DownloadAsync(IEnumerable<string> addresses, IProgress<BundleProgress>? progress = null, CancellationToken cancellationToken = default(CancellationToken))Downloads everything some addresses need, without loading any of it.
public int ClearCache(params IEnumerable<string> addresses)Deletes the cached copies of everything some addresses need.
public bool IsLoaded(string address)Whether an address is currently held by anyone.
public int ClaimCount(string address)How many claims are outstanding on an address.
Used by (39)
- ArenaThirdPersonShooter
- GameModelsThirdPersonShooter
- GameSoundsThirdPersonShooter
- PlayerRigThirdPersonShooter
- ProgramAddressablesRemote
- AppGraphicsVixen.App.Hosting
- AppServicesVixen.App.Hosting
- AssetHandleVixen.Assets
- AssetManagerTestsVixen.Assets.Tests
- AssetMaterialSourceVixen.Engine.Renderer
- AssetMaterialSourceTestsVixen.Engine.Renderer.Tests
- AssetMeshSourceVixen.Engine.Renderer
- AssetScopeVixen.Assets
- AssetTextureSourceVixen.Engine.Renderer
- AssetTextureSourceTestsVixen.Engine.Renderer.Tests
- AssetVfxEffectSourceVixen.Engine.Renderer
- AssetVirtualGeometrySourceVixen.Engine.Renderer
- ClaimResolverVixen.Assets
- CompositorContentTestsVixen.Assets.Tests
- ContentMountVixen.App.Hosting
- ContentReferenceTestsVixen.Assets.Tests
- ContentUpdateTestsVixen.Assets.Tests
- LooseContentSourceVixen.Assets
- ReferenceWorldVixen.Assets.Tests
- RemoteContentTestsVixen.Assets.Tests
- RemoteWorldVixen.Assets.Tests
- StreamedContentTestsVixen.Assets.Tests
- UpdateWorldVixen.Assets.Tests
- VixenApplicationVixen.App.Hosting
- WorldVixen.Assets.Tests
- WorldRendererVixen.Engine.Renderer
- WorldRendererTestsVixen.Engine.Renderer.Tests
- ContentBuilderTestsVixen.Editor.Assets.Tests
- ContentMountTestsVixen.App.Tests
- EditorContentVixen.Editor.App
- EditorContentTestsVixen.Editor.App.Tests
- LooseContentTestsVixen.Editor.Assets.Tests
- RemoteContentMountTestsVixen.App.Tests
- SceneManifestTestsVixen.Editor.Assets.Tests