Vixen
02b45cc4
csharp
public sealed class AssetTypeAttribute

Says what kind of asset an AssetId or AssetReference member is allowed to name, so that a picker offers only those and a drag carrying anything else is refused.

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

As a annotation

Valid on
Property, Field

Remarks

⚠ Here rather than in the editor, and that is the whole point of it. The editor has had an asset-picker attribute since the inspector was written, but a component in Vixen.Audio or in somebody's game cannot carry it — annotating a runtime type for the editor would be a runtime assembly referencing an editor one, which is the coupling doc 11's layering exists to prevent. So a runtime member had no way to say what it holds, and the answer the inspector fell back on was "any asset in the project", which for a clip member is a list with every texture and every scene in it.

⚠ A CLR type rather than a string kind. [AssetType("audio")] would need this assembly to define a vocabulary of asset kinds, and the set of kinds is the set of importers — which live in the editor and which a plugin adds to. A type is a name both ends already have: the member says AudioClip because that is what it resolves to at run time, and joining that to whichever importer produces one is the editor's job and stays there.

Advisory, exactly as RangeAttribute is: nothing at run time refuses an id of the wrong kind, because an id is sixteen bytes and knows nothing about what wrote it. This is what a person editing the value is offered.

Fields and properties (2)

  • public Type AssetType

    What the member resolves to.

  • public bool AllowNull

    Whether the member may hold nothing at all.

Methods (1)

  • public AssetTypeAttribute(Type assetType)

    Says what kind of asset an AssetId or AssetReference member is allowed to name, so that a picker offers only those and a drag carrying anything else is refused.

Used by (4)

  • MeshRenderableVixen.Rendering
  • PrimitiveShapeVixen.Rendering
  • VfxEmitterVixen.Rendering
  • ReflectedTypesVixen.Editor.Scripts