Table of Contents

Class MaterialContent

Namespace
Microsoft.Xna.Framework.Content.Pipeline.Graphics
Assembly
MonoGame.Framework.Content.Pipeline.dll

Provides methods and properties for maintaining a collection of named texture references.

public class MaterialContent : ContentItem
Inheritance
MaterialContent
Derived
Inherited Members

Remarks

In addition to texture references, opaque data values are stored in the OpaqueData property of the base class.

Constructors

MaterialContent()

Initializes a new instance of MaterialContent.

public MaterialContent()

Properties

Textures

Gets the texture collection of the material.

public TextureReferenceDictionary Textures { get; }

Property Value

TextureReferenceDictionary

Collection of textures used by the material.

Methods

Clone()

Helper method to make a copy of a material.

public MaterialContent Clone()

Returns

MaterialContent

A clone of the material.

GetReferenceTypeProperty<T>(string)

Gets a reference type from the OpaqueDataDictionary collection.

protected T GetReferenceTypeProperty<T>(string key) where T : class

Parameters

key string

Key of the property being retrieved.

Returns

T

The related opaque data.

Type Parameters

T

Type of the related opaque data.

GetTexture(string)

Gets a value from the Textures collection.

protected ExternalReference<TextureContent> GetTexture(string key)

Parameters

key string

Key of the texture being retrieved.

Returns

ExternalReference<TextureContent>

Reference to a texture from the collection.

GetValueTypeProperty<T>(string)

Gets a value type from the OpaqueDataDictionary collection.

protected T? GetValueTypeProperty<T>(string key) where T : struct

Parameters

key string

Key of the value type being retrieved.

Returns

T?

Index of the value type beng retrieved.

Type Parameters

T

Type of the value being retrieved.

SetProperty<T>(string, T)

Sets a value in the contained OpaqueDataDictionary object. If null is passed, the value is removed.

protected void SetProperty<T>(string key, T value)

Parameters

key string

Name of the key being modified.

value T

Value being set.

Type Parameters

T

Type of the element being set.

SetTexture(string, ExternalReference<TextureContent>)

Sets a value in the contained TextureReferenceDictionary object. If null is passed, the value is removed.

protected void SetTexture(string key, ExternalReference<TextureContent> value)

Parameters

key string

Name of the key being modified.

value ExternalReference<TextureContent>

Value being set.

Remarks

The key value differs depending on the type of attached dictionary. If attached to a BasicMaterialContent dictionary (which becomes a BasicEffect object at run time), the value for the Texture key is used as the texture for the BasicEffect runtime object. Other keys are ignored. If attached to a EffectMaterialContent dictionary, key names are the texture names used by the effect. These names are dependent upon the author of the effect object.