Vixen
dd8b0a81
csharp
public sealed class AssetDatabase

Every asset in a project, by GUID and by path.

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

Remarks

The GUID is the identity and the path is a fact about today. Everything stored in a file — a material's reference to a texture, a scene's reference to a prefab — is a GUID, so moving, renaming or reorganising folders changes nothing anywhere. This is the thing that makes that true: the one place that knows which GUID is currently at which path.

Rebuilt by scanning sidecars, and only their envelopes. [08](../../docs/plan/08-asset-pipeline-and-addressables.md) budgets a hundred-thousand asset rebuild at under ten seconds. That is achievable because MetaScanner reads three lines of each file and stops, and because the files are read in parallel — this is an I/O-bound walk, and the machine has cores idle during it.

And rebuilt incrementally. Each index entry records the size and write time of the sidecar it came out of, so a scan over an index that was loaded from Library/GuidIndex opens only the sidecars whose stamp has moved. That is what turns a cold start with one changed file from a full rebuild into a directory walk — the freshness question used to be asked once about the whole database, and a "no" cost everything. Every reuse is still checked against the disk, so the index cannot be believed into being wrong; the failure mode is a wasted read, never a missed asset.

Nothing here is silently tolerant. A file with no sidecar gets one; a sidecar with no file is moved aside rather than deleted, because a mis-ordered git operation should be recoverable; two assets claiming one GUID — the copy-pasted-folder disaster — are resolved by rule and reported by name. Silent tolerance is how projects rot, and every one of those is a real thing that happens to real projects weekly.

Fields and properties (3)

  • public ProjectPaths Paths

    Where the project's directories are.

  • public int Count

    How many assets are indexed.

  • public IReadOnlyCollection<AssetEntry> Entries

    Every asset, in no particular order.

Methods (7)

  • public AssetDatabase(ProjectPaths paths)

    Opens a database over a project.

  • public bool TryGetByGuid(AssetId guid, out AssetEntry entry)

    Finds an asset by its identity.

  • public bool TryGetByPath(string relativePath, out AssetEntry entry)

    Finds an asset by where it is.

  • public ScanReport Scan(ScanOptions? options = null)

    Brings the index up to date with the sidecars on disk.

  • public void Save()

    Writes the index to Library/GuidIndex.

  • public bool TryLoad()

    Reads the index back, if it is there and it is whole.

  • public bool IsStale()

    Whether a scan would change anything.

Used by (105, showing 40)

  • AddressableGroupEditorFactoryVixen.Editor.AssetEditors
  • AddressableGroupsViewVixen.Editor.AssetEditors
  • AgentFollowWiringTestsVixen.Editor.App.Tests
  • AnimationBinderVixen.Editor.AssetEditors
  • AnimationWiringTestsVixen.Editor.App.Tests
  • AssetDatabaseTestsVixen.Editor.Core.Tests
  • AssetEditorRegistryVixen.Editor.AssetEditors
  • AssetEditorRegistryTestsVixen.Editor.AssetEditors.Tests
  • AssetOperationTestsVixen.Editor.Core.Tests
  • AssetOperationsVixen.Editor.Core
  • AssetPickerVixen.Editor.App
  • AssetPickerTestsVixen.Editor.App.Tests
  • AssetPreviewContributionTestsVixen.Editor.App.Tests
  • AssetSearchSourceVixen.Editor.App
  • AssetWatchTestsVixen.Editor.App.Tests
  • BrowserCollectionTestsVixen.Editor.App.Tests
  • BrowserFileDropTestsVixen.Editor.App.Tests
  • ContentPipelineVixen.Editor.Assets
  • DiagnosticsModuleVixen.Editor.Diagnostics
  • DoctorRunnerVixen.Cli
  • DropIntoFieldTestsVixen.Editor.App.Tests
  • DropIntoSceneTestsVixen.Editor.App.Tests
  • EditorApplicationVixen.Editor.App
  • EditorCombinatorPairTestsVixen.Editor.App.Tests
  • EditorContentVixen.Editor.App
  • EditorContentTestsVixen.Editor.App.Tests
  • EditorContextVixen.Editor.Core
  • EditorProjectVixen.Editor.Core
  • EditorProjectTestsVixen.Editor.Core.Tests
  • EditorViewTestsVixen.Editor.AssetEditors.Tests
  • ExpiredRefusalTestsVixen.Editor.App.Tests
  • ExternalEditPumpTestsVixen.Editor.App.Tests
  • ExternalEditsVixen.Editor.Core
  • ExternalEditsTestsVixen.Editor.Core.Tests
  • FontDocumentVixen.Editor.AssetEditors
  • FramePresenterTestsVixen.Editor.App.Tests
  • GridViewTestsVixen.Editor.App.Tests
  • HarnessTestsVixen.Editor.App.Tests
  • ImportBudgetTestsVixen.Editor.Assets.Tests
  • ImportParallelismTestsVixen.Editor.Assets.Tests