Vixen
02b45cc4
csharp
public sealed class AssetHandle<T> where T : class

A claim on a loaded asset.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

A handle is a claim, not a reference. Holding one keeps the asset — and everything it depends on — in memory; releasing it gives that claim up. The asset itself is unloaded when the last claim goes, which is what lets two scenes share a texture without either of them knowing about the other.

Releasing twice throws. It is tempting to make it a no-op, and that is exactly what turns a double release into someone else's asset being unloaded: the second call decrements a count that a different holder is relying on, and the failure surfaces much later as a disposed object nobody released. Unity's addressables are a documented source of this class of bug. Throwing at the second call names it where it happened.

Fields and properties (5)

  • public string Address

    What was asked for.

  • public ImmutableArray<string> Acquired

    Every address this handle is holding a claim on — the asset and its dependencies.

  • public AssetStatus Status

    Where the load has got to.

  • public T Result

    What was loaded.

  • public Task<T> Completion

    The load, as a task.

Methods (2)

  • public TaskAwaiter<T> GetAwaiter()

    Makes the handle awaitable, so await handle gives the asset.

  • public void Release()

    Gives up this handle's claim.

Used by (23)

  • ArenaThirdPersonShooter
  • GameSoundsThirdPersonShooter
  • PlayerRigThirdPersonShooter
  • ProgramAddressablesRemote
  • AppGraphicsVixen.App.Hosting
  • AssetManagerVixen.Assets
  • AssetManagerTestsVixen.Assets.Tests
  • AssetMaterialSourceVixen.Engine.Renderer
  • AssetMeshSourceVixen.Engine.Renderer
  • AssetScopeVixen.Assets
  • AssetVfxEffectSourceVixen.Engine.Renderer
  • AssetVirtualGeometrySourceVixen.Engine.Renderer
  • CompositorContentTestsVixen.Assets.Tests
  • ContentReferenceTestsVixen.Assets.Tests
  • EntryVixen.Engine.Renderer
  • EntryVixen.Engine.Renderer
  • EntryVixen.Engine.Renderer
  • RemoteContentTestsVixen.Assets.Tests
  • VixenApplicationVixen.App.Hosting
  • ContentBuilderTestsVixen.Editor.Assets.Tests
  • ContentMountTestsVixen.App.Tests
  • RemoteContentMountTestsVixen.App.Tests
  • SceneManifestTestsVixen.Editor.Assets.Tests