# Sandbox.Engine.MaterialAccessor

A wrapper to allow the unification of editing materials. This is usually a member on a Component which implements MaterialAccessor.ITarget.

## Examples

```csharp
MaterialAccessor materialAccessor;

[Property]
public MaterialAccessor Materials => materialAccessor ??= new MaterialAccessor( this );
```

- Kind: class
- Namespace: `Sandbox.Engine`
- Assembly: `Sandbox.Engine`
- Modifiers: sealed

## Constructors

- [`MaterialAccessor`](/api/Sandbox.Engine.MaterialAccessor/.ctor): Create a new material accessor for this object.

## Properties

- [`Count`](/api/Sandbox.Engine.MaterialAccessor/Count): Total number of material slots

## Methods

- [`Apply`](/api/Sandbox.Engine.MaterialAccessor/Apply): Apply to the object. You don't need to call this when setting overrides, as it will automatically apply them to the target when you set them. This is here as a convenience if this object holds data, and you need to apply it to another object that didn't exist when the overrides were originally set, or loaded.
- [`GetOriginal`](/api/Sandbox.Engine.MaterialAccessor/GetOriginal): Get the original material for the specified index.
- [`GetOverride`](/api/Sandbox.Engine.MaterialAccessor/GetOverride): Get the override material for this slot. Or null if not set.
- [`HasOverride`](/api/Sandbox.Engine.MaterialAccessor/HasOverride): Does this index have an override material?
- [`SetOverride`](/api/Sandbox.Engine.MaterialAccessor/SetOverride): Set an override material for this slot. If the material is null, it will clear the override.
