Class VolumeComponent
The base class for all the components that can be part of a VolumeProfile. The Volume framework automatically handles and interpolates any VolumeParameter members found in this class.
Namespace: UnityEngine.Rendering
Syntax
[Serializable]
public class VolumeComponent : ScriptableObject
Examples
using UnityEngine.Rendering;
[Serializable, VolumeComponentMenu("Custom/Example Component")]
public class ExampleComponent : VolumeComponent
{
public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f);
}
Fields
active
The active state of the set of parameters defined in this class. You can use this to quickly turn on or off all the overrides at once.
Declaration
public bool active
Field Value
Type | Description |
---|---|
Boolean |
Properties
displayName
The name displayed in the component header. If you do not set a name, Unity generates one from the class name automatically.
Declaration
public string displayName { get; protected set; }
Property Value
Type | Description |
---|---|
String |
parameters
A read-only collection of all the VolumeParameters defined in this class.
Declaration
public ReadOnlyCollection<VolumeParameter> parameters { get; }
Property Value
Type | Description |
---|---|
ReadOnlyCollection<VolumeParameter> |
Methods
GetHashCode()
A custom hashing function that Unity uses to compare the state of parameters.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A computed hash code for the current instance. |
OnDisable()
Unity calls this method when the object goes out of scope.
Declaration
protected virtual void OnDisable()
OnEnable()
Unity calls this method when it loads the class.
Declaration
protected virtual void OnEnable()
Remarks
If you want to override this method, you must call base.OnEnable()
.
Override(VolumeComponent, Single)
Interpolates a VolumeComponent with this component by an interpolation factor and puts the result back into the given VolumeComponent.
Declaration
public virtual void Override(VolumeComponent state, float interpFactor)
Parameters
Type | Name | Description |
---|---|---|
VolumeComponent | state | The internal component to interpolate from. You must store the result of the interpolation in this same component. |
Single | interpFactor | The interpolation factor in range [0,1]. |
Remarks
You can override this method to do your own blending. Either loop through the parameters list or reference direct fields. You should only use SetValue(VolumeParameter) to set parameter values and not assign directly to the state object. you should also manually check overrideState before you set any values.
Examples
Below is the default implementation for blending:
public virtual void Override(VolumeComponent state, float interpFactor)
{
int count = parameters.Count;
for (int i = 0; i < count; i++)
{
var stateParam = state.parameters[i];
var toParam = parameters[i];
// Keep track of the override state for debugging purpose
stateParam.overrideState = toParam.overrideState;
if (toParam.overrideState)
stateParam.Interp(stateParam, toParam, interpFactor);
}
}
SetAllOverridesTo(Boolean)
Sets the state of all the overrides on this component to a given value.
Declaration
public void SetAllOverridesTo(bool state)
Parameters
Type | Name | Description |
---|---|---|
Boolean | state | The value to set the state of the overrides to. |