AutoDepthOfFieldAPI static API
Control PBADOF lifecycle, presets, override volume state, and focus solving through the AutoDepthOfFieldAPI static compatibility facade.
AutoDepthOfFieldAPI static API
HIBIKI entertainment's AutoDepthOfFieldAPI class is a static compatibility facade that provides convenience access to PBADOF lifecycle management, preset operations, override volume state, and focus-solving helpers. It forwards to the active AutoDepthOfField component when one is available.
The API facade methods forward to the active output-owning AutoDepthOfField component. If no component is active, methods silently no-op or return default values. For direct component access, use AutoDepthOfField.TryGetCurrent instead.
Output and lifecycle
| Method | Parameters | Description |
|---|---|---|
SetupDOFVolume(Volume, VolumeProfile, float) | volume: target Volume, profile: VolumeProfile asset, blendWeight: blend weight (default 1) | Configures a Unity Volume with the supplied profile and blend weight. |
UpdateGlobalFocalLength(float) | value: focal length in millimetres | Updates the global focal length on the active component. |
SetSystemState(bool) | isActive: desired state | Activates or deactivates the PBADOF system. |
GetOperatingMode() | None | Returns the current owner's AutoDepthOfFieldOperatingMode. Returns Off if no owner is active. |
SetOperatingMode(AutoDepthOfFieldOperatingMode) | mode: Automatic (0), ManualFocus (1), or Off (2) | Sets the operating mode on the current owner. No-op if no owner is active. |
SetDepthOfFieldRenderState(bool) | isActive: desired state | Activates or deactivates the depth-of-field render pass. |
SetDepthOfFieldQuality(DepthOfFieldQualityData) | quality: quality data asset | Sets the rendering quality for the depth-of-field effect. |
StartFocalLengthUpdate() | None | Begins the focal-length update cycle on the active component. |
Operating modes control how PBADOF interacts with external focus sources. Automatic (0) drives autofocus and all output. ManualFocus (1) preserves an external Camera.focusDistance while PBADOF controls lens and DoF. Off (2) disables DoF output but preserves lens values. See the Focus system page for full details.
Presets
| Method | Parameters | Description |
|---|---|---|
ApplyPreset(DepthOfFieldPreset) | preset: the preset to apply | Applies the given preset to the active component. |
SavePreset(DepthOfFieldPreset) | preset: the preset to save | Saves the active component's current settings into the given preset asset. |
GetDefaultPreset() | None | Returns the built-in default preset. |
Override volume state
| Method | Parameters | Description |
|---|---|---|
SetIsInVolume(bool, AutoDepthOfFieldVolumeData) | inVolume: whether inside a volume, data: volume data | Reports volume-entered state with explicit volume data. |
SetIsInVolume(bool) | inVolume: whether inside a volume | Reports volume-entered state without explicit data. |
SetAimingState(bool) | value: aiming state | Sets the aim-down-sight state for ADS volume resolution. |
BuildOverrideVolumes(bool) | ignoreCheckTime: skip time-based throttle | Rebuilds the override volume database. |
CreateADSVolume() | None | Creates and returns a new ADS override volume. |
CreateADSVolume(AutoDepthOfField) | owner: explicit owner component | Creates a new ADS volume with a specified owner. |
CreateAdvancedVolume() | None | Creates and returns a new CameraFallback override volume. |
CreateAdvancedVolume(AutoDepthOfField) | owner: explicit owner component | Creates a new CameraFallback volume with a specified owner. |
CreateOverrideVolume(Vector3, Vector3, Vector3, DepthOfFieldPreset, string, bool) | volumePosition, volumeSize, volumeRotation, preset, volumeName, showGizmos | Creates a spatial override volume with full configuration. Returns the volume data. |
GetCurrentVolumeData(Dictionary<int, AutoDepthOfFieldVolumeData>) | database: volume database | Returns the data for the currently active volume. |
AddVolumeToDatabase(int, AutoDepthOfFieldVolumeData) | ID: volume ID, data: volume data | Adds a volume to the database. |
RemoveVolumeToDatabase(int) | ID: volume ID | Removes a volume from the database. |
CacheAllSceneVolumeColliders(AutoDepthOfFieldData) | data: component data | Caches colliders for all scene volumes. |
ResetAllVolumesDOFEnabledValues() | None | Resets the DOF-enabled flag on all volumes. |
Focus compatibility helpers
| Method | Parameters | Description |
|---|---|---|
CalculateFocusPoint(Camera, AutoDepthOfFieldData, float, float, RaycastHit[], float, out float, out int, bool) | mainCamera, data, fov, maxDistance, glassResults (retained for compatibility, not used as shared state), glassCorrection, out groundDistance, out closestRay, clearCache | Calculates the focus point using the component-owned solver. Returns the focus distance. |
AssignRaycastHit(AutoDepthOfFieldData, ref RaycastHit, Vector3, bool) | data, ref raycastHit, playerPosition, sortClosest | Assigns a raycast hit to the focus solver. Returns success. |
TagCheck(RaycastHit, List<string>, bool) | hit, tags, useTagCheck | Checks whether a hit's tag is in the allowed list. Returns the match result. |
CheckClosest(Camera, float, RaycastHit, int, out int) | mainCamera, oldValue, raycast, rayID, out closestRay | Compares a raycast against the current closest hit. Returns the distance. |
The CalculateFocusPoint method retains the glassResults parameter for source and binary compatibility, but the implementation forwards to the component-owned solver and does not use it as shared solver state.
Editor-only members
| Member | Type | Description |
|---|---|---|
CacheTags() | Method (editor-only) | Populates the internal tag cache from Unity's editor tag list. Only compiled in the Unity Editor. |
Public static fields
| Field | Type | Description |
|---|---|---|
RaycastCacheLimit | int | Maximum number of cached raycast hits. |
m_cachedRaycastHits | RaycastHit[] | Cached raycast hit buffer. |
Usage examples
// Activate the PBADOF system
AutoDepthOfFieldAPI.SetSystemState(true);
// Set quality
AutoDepthOfFieldAPI.SetDepthOfFieldQuality(myQualityData);
// Update focal length
AutoDepthOfFieldAPI.UpdateGlobalFocalLength(50f);
// Apply a preset
AutoDepthOfFieldAPI.ApplyPreset(myPreset);
// Save current settings to a preset
AutoDepthOfFieldAPI.SavePreset(myPreset);
// Get the default
DepthOfFieldPreset defaults = AutoDepthOfFieldAPI.GetDefaultPreset();
// Create a spatial override volume
var volumeData = AutoDepthOfFieldAPI.CreateOverrideVolume(
volumePosition: transform.position,
volumeSize: new Vector3(10f, 5f, 10f),
volumeRotation: transform.eulerAngles,
preset: myPreset,
volumeName: "Room Focus Zone",
showGizmos: true
);
// Rebuild the volume database after runtime changes
AutoDepthOfFieldAPI.BuildOverrideVolumes(ignoreCheckTime: true);
// Switch to manual focus. External systems control focus distance
AutoDepthOfFieldAPI.SetOperatingMode(
AutoDepthOfFieldOperatingMode.ManualFocus);
// Check the current mode
var mode = AutoDepthOfFieldAPI.GetOperatingMode();
// Disable DoF output entirely
AutoDepthOfFieldAPI.SetOperatingMode(
AutoDepthOfFieldOperatingMode.Off);
Next steps
See the AutoDepthOfField component for the main component API, or the Override volume and focus proxy API for component-level volume and proxy interfaces.