Skip to content

Content Metadata Files

Cole Campbell edited this page Mar 3, 2018 · 2 revisions

Ultraviolet's content importers and processors are designed to "just work" under common use cases. However, it may at times be necessary to specify custom loading parameters for specific content assets. This can be done by creating content metadata files and associating them with the asset in question.

Content Metadata

Content metadata files are XML files with the .uvmeta file extension. When a content metadata file is loaded through the content subsystem, Ultraviolet reads the metadata file in order to find the associated asset file. It then loads that asset file as it normally would, except that it feeds the metadata specified by the content metadata file into the content importer and content processor.

Content metadata files have the following format:

<?xml version="1.0" encoding="utf-8" ?>
<AssetMetadata>
  <Asset>AssociatedContentFile.png</Asset>
  <ImporterMetadata>
    <Hello>foo</Hello>
  </ImporterMetadata>
  <ProcessorMetadata>
    <World>bar</World>    
  </ProcessorMetadata>
</AssetMetadata>

The <Asset> element specifies the name of the content asset that is associated with the metadata file. If we call the above file Foo.uvmeta, then the code contentManager.Load<Texture2D>("Foo") will ultimately load the AssociatedContentFile.png asset.

The <ImporterMetadata> element contains the metadata which is passed to the content importer; the structure of this data will differ from importer to importer.

The <ProcessorMetadata> element, analogously to <ImporterMetadata>, contains metadata which is passed to the content processor.

As an example of how content metadata can be used, the OpenGLTexture2DProcessor specifies a metadata property called PremultiplyAlpha. If this property is set to false in the processor metadata, as in the example below, then the texture processor will skip the loading step which premultiplies the source file's alpha.

<?xml version="1.0" encoding="utf-8" ?>
<AssetMetadata>
  <Asset>AssociatedContentFile.png</Asset>
  <ImporterMetadata />
  <ProcessorMetadata>
    <PremultiplyAlpha>false</PremultiplyAlpha>    
  </ProcessorMetadata>
</AssetMetadata>
Clone this wiki locally