API referenceOverride volume and focus proxy API

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

RoleValueDescription
Spatial0Region-based volume that overrides settings when the camera or target is inside its bounds.
CameraFallback1Behavioural volume that provides fallback settings when no spatial volume is active.
ADS2Aim-down-sight volume that overrides settings during aiming state.

Public properties

PropertyTypeDescription
VolumeActiveboolWhether this volume is currently active.
VolumeDataAutoDepthOfFieldVolumeDataThe serialised override data. Replaced with a new instance if set to null.
BoundsBoundsCompatibility world-space axis-aligned bounding box.
WorldBoundsBoundsWorld-space bounds calculated from the local box, transform rotation, and scale.
IDintLegacy volume identifier. No longer determines ordering or ownership.
RoleAutoDepthOfFieldVolumeRoleThe volume's role: Spatial, CameraFallback, or ADS.
PriorityintContribution precedence. Higher priority overrides lower priority.
IsADSVolumeboolCompatibility property that is true when Role == ADS.
IsAdvancedVolumeboolCompatibility property that is true when Role == CameraFallback.
HasOverridesboolWhether the volume data has any override flags enabled.
SerializedVersionintThe serialised migration version.

Public fields

FieldTypeDefaultDescription
m_showGizmosboolfalseWhether to draw gizmos for this volume.
m_gizmoColorColor32(39, 192, 149, 107)Gizmo colour.

Public methods

MethodParametersDescription
ResetVolume()NoneClears the volume data reset flag.
ApplyPreset(DepthOfFieldPreset)preset: preset to applyCopies preset values into the volume while preserving existing override-state flags.
InitializeVolume(bool)buildBounds, default trueMigrates data, optionally rebuilds bounds, and registers the volume with the resolver when active.
BuildBounds()NoneRebuilds and returns the compatibility world-space axis-aligned bounding box.
BuildBounds(int)volumeID: legacy IDSets the legacy ID, then rebuilds the bounds.
ContainsPoint(Vector3)worldPoint: point to testTests whether the point lies inside the configured local-space box. Returns false for non-spatial roles.
MigrateIfNeeded()NoneMigrates legacy ADS or advanced flags and transition-time data to the current format. Returns true when migration occurred.
ProcessUpdate()NoneCompatibility 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

PropertyTypeDescription
VisualRootTransformRenderer hierarchy used when fitting the proxy. If unset, fitting uses the proxy's own transform.
PaddingVector3Extra local-space padding around the calculated renderer bounds. Clamped to non-negative values.
ProxyColliderBoxColliderThe required BoxCollider component.

Public methods

MethodParametersDescription
FitToVisuals()NoneFits 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

PropertyTypeDefaultDescription
FocusPointTransformnoneOptional preferred focus point. When set, optical depth is calculated from this point instead of the raw collider hit.
Priorityfloat (0.25–4.0)1.0Multiplier 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

PropertyTypeDescription
ExtendedFocusDistanceClampedFloatParameterExtended focus distance value with override state.
BaseApertureClampedFloatParameterBase aperture value with override state.
ExtendedApertureClampedFloatParameterExtended aperture value with override state.
DepthOfFieldQualityDepthOfFieldQualityDataQuality 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:

PropertyTypeDescription
AperturefloatAperture value.
FocalLengthfloatFocal length value.
FocusDistancefloatFocus 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.