From 0a0ade32324b844220869ae506809f2fa246f701 Mon Sep 17 00:00:00 2001 From: Gregory Labute Date: Tue, 15 Jul 2025 13:39:05 -0400 Subject: [PATCH] Fix Focal Length and Aperture not updating with auto-focus Resolved an issue where changes to Focal Length and Aperture in CinemachineVolumeSettings were not applied when auto-focus was enabled. The fix ensures these properties are now correctly updated and reflected in the dynamic DepthOfField settings. --- com.unity.cinemachine/CHANGELOG.md | 7 +++++++ .../PostProcessing/CinemachineVolumeSettings.cs | 11 ++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/com.unity.cinemachine/CHANGELOG.md b/com.unity.cinemachine/CHANGELOG.md index d0847fc59..6877dd401 100644 --- a/com.unity.cinemachine/CHANGELOG.md +++ b/com.unity.cinemachine/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [3.1.5] - 2025-012-31 +### Unreleased + +### Bugfixes +- CinemachineVolumeSettings: changes to Focal Length and Aperture settings were not being applied while auto-focus was enabled. + + ## [3.1.4] - 2025-06-10 ### Bugfixes diff --git a/com.unity.cinemachine/Runtime/PostProcessing/CinemachineVolumeSettings.cs b/com.unity.cinemachine/Runtime/PostProcessing/CinemachineVolumeSettings.cs index 567ac8bdf..f9a603b88 100644 --- a/com.unity.cinemachine/Runtime/PostProcessing/CinemachineVolumeSettings.cs +++ b/com.unity.cinemachine/Runtime/PostProcessing/CinemachineVolumeSettings.cs @@ -182,8 +182,7 @@ protected override void PostPipelineStageCallback( { if (extra.ProfileCopy == null) extra.CreateProfileCopy(Profile); - profile = extra.ProfileCopy; - if (profile.TryGet(out DepthOfField dof)) + if (extra.ProfileCopy.TryGet(out DepthOfField dof)) { float focusDistance = FocusOffset; if (FocusTracking == FocusTrackingMode.LookAtTarget) @@ -203,8 +202,14 @@ protected override void PostPipelineStageCallback( CalculatedFocusDistance = focusDistance = Mathf.Max(0, focusDistance); dof.focusDistance.value = focusDistance; state.Lens.PhysicalProperties.FocusDistance = focusDistance; - profile.isDirty = true; + if (profile.TryGet(out DepthOfField srcDof)) + { + dof.aperture.value = srcDof.aperture.value; + dof.focalLength.value = srcDof.focalLength.value; + } + extra.ProfileCopy.isDirty = true; } + profile = extra.ProfileCopy; } // Apply the post-processing state.AddCustomBlendable(new CameraState.CustomBlendableItems.Item { Custom = profile, Weight = Weight });