Vixen
02b45cc4
csharp
public abstract class ImportSettingsDocument

An asset's import settings, open for editing: the base, the per-target overrides, and where it appears in a build.

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

Remarks

It edits the sidecar's node tree, not a bound AssetMeta. Binding and re-emitting would be shorter and would throw away two things the file carries and the schema does not: the per-target overrides block, which TargetOverrides resolves at import time and no settings type has a member for, and any key a newer editor wrote that this one does not know about. A settings editor that silently deleted either would turn opening a file into an edit.

What the inspector edits is a mirror, and there is a test that says so. The settings records are init-only for the pipeline's sake — a record whose fields can be written after it has been hashed into a cache key is a footgun — so the editable object beside each one is a class with the same member names and types. ImportSettingsMirrorTests compares the two by reflection, so a setting added to an importer and not to its mirror is a red test rather than a knob nobody can turn.

⚠ Saving writes the sidecar and nothing else. Changing how a texture is compressed does not re-import it; what re-imports it is the import pass noticing that the settings hash moved. A document that ran an import inside Save would make Ctrl+S take thirty seconds on a model.

Fields and properties (9)

  • public string AssetPath

    Where the asset itself is, absolute.

  • public string MetaPath

    Where its sidecar is, absolute.

  • public object Settings

    The base settings, which every target starts from.

  • public AddressableEdits Addressable

    Where the asset appears in a shipped build.

  • public IReadOnlyList<SubAssetEntry> SubAssets

    What the last import produced inside this asset, as the sidecar recorded it.

  • public IReadOnlyList<TargetOverride> Overrides

    The per-target overrides, in the order the file listed them.

  • public IReadOnlyList<string> UnknownKeys

    Keys in the sidecar that matched no member, reported rather than dropped silently.

  • protected abstract Type SettingsType

    The type of Settings, which is the mirror rather than the record.

  • protected abstract string ImporterTag

    The importer's name, which is the sidecar's type tag.

Events (1)

  • public Action<ImportSettingsDocument>? OverridesChanged

    Raised when a target is added or removed, or a member's override is turned on or off.

Methods (7)

  • protected ImportSettingsDocument(EditorProject project, AssetId asset, string path)

    Opens an asset's import settings.

  • public TargetOverride AddTarget(string target)

    Adds a target with nothing overridden yet, undoably.

  • public bool RemoveTarget(string target)

    Removes a target's row, undoably.

  • public bool SetOverridden(TargetOverride row, string member, bool overridden)

    Turns one member's override on or off for one target, undoably.

  • public TargetOverride? Find(string target)

    The row for a target, if it has one.

  • public string ToYaml()

    The sidecar as this document would write it, without writing it.

  • protected override void SaveCore()

    Writes the document back to wherever it came from.

Used by (13)

  • AddTargetCommandVixen.Editor.AssetEditors
  • ImportSettingsDocumentTestsVixen.Editor.AssetEditors.Tests
  • ImportSettingsViewVixen.Editor.AssetEditors
  • ImportViewTestsVixen.Editor.AssetEditors.Tests
  • ModelImportDocumentVixen.Editor.AssetEditors
  • ModelImportViewVixen.Editor.AssetEditors
  • RemoveTargetCommandVixen.Editor.AssetEditors
  • SetOverriddenCommandVixen.Editor.AssetEditors
  • SpriteDocumentTestsVixen.Editor.AssetEditors.Tests
  • SpriteSheetViewVixen.Editor.AssetEditors
  • TargetOverrideMatrixVixen.Editor.AssetEditors
  • TextureImportDocumentVixen.Editor.AssetEditors
  • TextureImportViewVixen.Editor.AssetEditors