Override volume and focus proxy API
Access override volume properties and methods, fit focus proxy colliders at runtime, and implement custom extensions through the IAutoDepthOfFieldExtension interface.
Override volume and focus proxy API
HIBIKI entertainment's override volume and focus proxy components expose public APIs for runtime inspection, configuration, and custom workflows. The extension interface lets you inject custom focus and lens modifications into the solver pipeline.
AutoDepthOfFieldOverrideVolume
AutoDepthOfFieldOverrideVolume is a MonoBehaviour that represents a spatial or behavioural override region in the scene. It registers with the resolver and contributes focus, lens, and filtering overrides based on its role and priority.
Volume roles enum
| Role | Value | Description |
|---|---|---|
Spatial | 0 | Region-based volume that overrides settings when the camera or target is inside its bounds. |
CameraFallback | 1 | Behavioural volume that provides fallback settings when no spatial volume is active. |
ADS | 2 | Aim-down-sight volume that overrides settings during aiming state. |
Public properties
| Property | Type | Description |
|---|---|---|
VolumeActive | bool | Whether this volume is currently active. |
VolumeData | AutoDepthOfFieldVolumeData | The serialised override data. Replaced with a new instance if set to null. |
Bounds | Bounds | Compatibility world-space axis-aligned bounding box. |
WorldBounds | Bounds | World-space bounds calculated from the local box, transform rotation, and scale. |
ID | int | Legacy volume identifier. No longer determines ordering or ownership. |
Role | AutoDepthOfFieldVolumeRole | The volume's role: Spatial, CameraFallback, or ADS. |
Priority | int | Contribution precedence. Higher priority overrides lower priority. |
IsADSVolume | bool | Compatibility property that is true when Role == ADS. |
IsAdvancedVolume | bool | Compatibility property that is true when Role == CameraFallback. |
HasOverrides | bool | Whether the volume data has any override flags enabled. |
SerializedVersion | int | The serialised migration version. |
Public fields
| Field | Type | Default | Description |
|---|---|---|---|
m_showGizmos | bool | false | Whether to draw gizmos for this volume. |
m_gizmoColor | Color32 | (39, 192, 149, 107) | Gizmo colour. |
Public methods
| Method | Parameters | Description |
|---|---|---|
ResetVolume() | None | Clears the volume data reset flag. |
ApplyPreset(DepthOfFieldPreset) | preset: preset to apply | Copies preset values into the volume while preserving existing override-state flags. |
InitializeVolume(bool) | buildBounds, default true | Migrates data, optionally rebuilds bounds, and registers the volume with the resolver when active. |
BuildBounds() | None | Rebuilds and returns the compatibility world-space axis-aligned bounding box. |
BuildBounds(int) | volumeID: legacy ID | Sets the legacy ID, then rebuilds the bounds. |
ContainsPoint(Vector3) | worldPoint: point to test | Tests whether the point lies inside the configured local-space box. Returns false for non-spatial roles. |
MigrateIfNeeded() | None | Migrates legacy ADS or advanced flags and transition-time data to the current format. Returns true when migration occurred. |
ProcessUpdate() | None | Compatibility polling entry point. Reports whether the volume is active relative to the current owner. |
AutoDepthOfFieldFocusProxy
AutoDepthOfFieldFocusProxy is a sealed MonoBehaviour that requires a BoxCollider. It fits that collider around child renderers so PBADOF raycasts can hit objects that contain renderers but no suitable physics collider.
The focus proxy enforces [DisallowMultipleComponent] and [RequireComponent(typeof(BoxCollider))]. Unity adds the BoxCollider automatically when you add the proxy.
Public properties
| Property | Type | Description |
|---|---|---|
VisualRoot | Transform | Renderer hierarchy used when fitting the proxy. If unset, fitting uses the proxy's own transform. |
Padding | Vector3 | Extra local-space padding around the calculated renderer bounds. Clamped to non-negative values. |
ProxyCollider | BoxCollider | The required BoxCollider component. |
Public methods
| Method | Parameters | Description |
|---|---|---|
FitToVisuals() | None | Fits the required box collider to all child renderers below VisualRoot. Returns true if at least one renderer was found. Enforces isTrigger = false. |
Usage example
The following example fits a weapon proxy to its visual hierarchy and then reads the resulting collider bounds.
using UnityEngine;
using HIBIKIentertainment.DepthOfField;
public class WeaponFocusProxySetup : MonoBehaviour
{
[SerializeField] private Transform weaponVisualRoot;
private void Start()
{
var proxy = GetComponent<AutoDepthOfFieldFocusProxy>();
proxy.VisualRoot = weaponVisualRoot;
proxy.Padding = new Vector3(0.05f, 0.05f, 0.05f);
if (proxy.FitToVisuals())
{
Bounds bounds = proxy.ProxyCollider.bounds;
Debug.Log($"Focus proxy fitted to {bounds.size}.");
}
}
}
AutoDepthOfFieldFocusTarget
AutoDepthOfFieldFocusTarget is a sealed MonoBehaviour that identifies a semantic autofocus subject. In Smart Subject mode, colliders on this GameObject and its children are grouped as one stable subject rather than treated as individual hits.
Add it from the component menu: HIBIKI Entertainment / Depth Of Field / Auto Depth Of Field Focus Target. The component enforces [DisallowMultipleComponent].
Public properties
| Property | Type | Default | Description |
|---|---|---|---|
FocusPoint | Transform | none | Optional preferred focus point. When set, optical depth is calculated from this point instead of the raw collider hit. |
Priority | float (0.25–4.0) | 1.0 | Multiplier applied to the subject's cluster ray weights during scoring. |
Usage example
The following example adds a focus target to a character and biases the solver towards it.
using UnityEngine;
using HIBIKIentertainment.DepthOfField;
// Add AutoDepthOfFieldFocusTarget to a character at runtime
var target = myCharacter.AddComponent<AutoDepthOfFieldFocusTarget>();
target.FocusPoint = myCharacter.transform; // Use the character root as the focus point
target.Priority = 2.0f; // Score this subject twice as strongly
// Bias the solver towards this character
if (AutoDepthOfField.TryGetCurrent(out var dof))
{
dof.SetFocusHint(target, strength: 4f);
}
The Priority property is clamped to 0.25–4.0. A value of 2.0 doubles the subject's effective score; 0.5 halves it. The default of 1.0 means the subject scores on its raw ray weights alone.
Extension interface
The IAutoDepthOfFieldExtension interface lets you inject custom focus and lens modifications into the solver pipeline.
Interface
public interface IAutoDepthOfFieldExtension
{
void Execute(AutoDepthOfField dof);
}
Implement Execute to run extension logic against the active AutoDepthOfField component.
ExtensionBaseData properties
| Property | Type | Description |
|---|---|---|
ExtendedFocusDistance | ClampedFloatParameter | Extended focus distance value with override state. |
BaseAperture | ClampedFloatParameter | Base aperture value with override state. |
ExtendedAperture | ClampedFloatParameter | Extended aperture value with override state. |
DepthOfFieldQuality | DepthOfFieldQualityData | Quality data for the extension. |
Built-in extension: ExtendFocusDistanceExtension
ExtendFocusDistanceExtension implements IAutoDepthOfFieldExtension and applies ExtendedFocusDistance when that parameter's overrideState is enabled. It exposes a public ExtensionSettings field of type ExtensionBaseData.
CinemachineData
CinemachineData is a lightweight data container used by the Cinemachine 3 adapter. It exposes the following properties:
| Property | Type | Description |
|---|---|---|
Aperture | float | Aperture value. |
FocalLength | float | Focal length value. |
FocusDistance | float | Focus distance value. |
Usage example: custom extension
The following extension stores its own settings and checks the ExtendedFocusDistance override state during execution.
using UnityEngine;
using HIBIKIentertainment.DepthOfField;
public class WeaponZoomExtension : MonoBehaviour, IAutoDepthOfFieldExtension
{
public ExtensionBaseData settings = new ExtensionBaseData();
public void Execute(AutoDepthOfField dof)
{
// Apply extended focus distance when zoomed.
if (settings.ExtendedFocusDistance.overrideState)
{
// The solver reads ExtendedFocusDistance from this extension.
}
}
}
Next steps
See the AutoDepthOfField component for the main component API, or the AutoDepthOfFieldAPI static API for the static compatibility facade.