Skip to content

Commit 529e59a

Browse files
authored
Fix Focal Length and Aperture not updating with auto-focus (#1067)
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.
1 parent 116c84b commit 529e59a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

com.unity.cinemachine/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88
### Unreleased
99

1010
### Bugfixes
11+
- CinemachineVolumeSettings: changes to Focal Length and Aperture settings were not being applied while auto-focus was enabled.
1112
- InheritPosition was not inheriting the camera position in all cases.
1213

1314
### Added

com.unity.cinemachine/Runtime/PostProcessing/CinemachineVolumeSettings.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ protected override void PostPipelineStageCallback(
182182
{
183183
if (extra.ProfileCopy == null)
184184
extra.CreateProfileCopy(Profile);
185-
profile = extra.ProfileCopy;
186-
if (profile.TryGet(out DepthOfField dof))
185+
if (extra.ProfileCopy.TryGet(out DepthOfField dof))
187186
{
188187
float focusDistance = FocusOffset;
189188
if (FocusTracking == FocusTrackingMode.LookAtTarget)
@@ -203,8 +202,14 @@ protected override void PostPipelineStageCallback(
203202
CalculatedFocusDistance = focusDistance = Mathf.Max(0, focusDistance);
204203
dof.focusDistance.value = focusDistance;
205204
state.Lens.PhysicalProperties.FocusDistance = focusDistance;
206-
profile.isDirty = true;
205+
if (profile.TryGet(out DepthOfField srcDof))
206+
{
207+
dof.aperture.value = srcDof.aperture.value;
208+
dof.focalLength.value = srcDof.focalLength.value;
209+
}
210+
extra.ProfileCopy.isDirty = true;
207211
}
212+
profile = extra.ProfileCopy;
208213
}
209214
// Apply the post-processing
210215
state.AddCustomBlendable(new CameraState.CustomBlendableItems.Item { Custom = profile, Weight = Weight });

0 commit comments

Comments
 (0)