@@ -278,7 +278,7 @@ void ReplaceData(PostProcessLayer postProcessLayer)
278
278
}
279
279
}
280
280
281
- internal void UpdateSettings ( PostProcessLayer postProcessLayer )
281
+ internal void UpdateSettings ( PostProcessLayer postProcessLayer , Camera camera )
282
282
{
283
283
// Reset to base state
284
284
ReplaceData ( postProcessLayer ) ;
@@ -295,6 +295,12 @@ internal void UpdateSettings(PostProcessLayer postProcessLayer)
295
295
// Traverse all volumes
296
296
foreach ( var volume in volumes )
297
297
{
298
+ #if UNITY_EDITOR
299
+ // Skip volumes that aren't in the scene currently displayed in the scene view
300
+ if ( ! IsVolumeRenderedByCamera ( volume , camera ) )
301
+ continue ;
302
+ #endif
303
+
298
304
// Skip disabled volumes and volumes without any data or weight
299
305
if ( ! volume . enabled || volume . profileRef == null || volume . weight <= 0f )
300
306
continue ;
@@ -407,5 +413,19 @@ static void SortByPriority(List<PostProcessVolume> volumes)
407
413
volumes [ j + 1 ] = temp ;
408
414
}
409
415
}
416
+
417
+ static bool IsVolumeRenderedByCamera ( PostProcessVolume volume , Camera camera )
418
+ {
419
+ #if UNITY_2018_3_OR_NEWER && UNITY_EDITOR
420
+ // If the current camera have a custom scene then the camera is rendering that scene,
421
+ // otherwise the camera is rendering the scenes in the SceneManager.
422
+ var customScene = camera . scene ;
423
+ return customScene . IsValid ( )
424
+ ? UnityEditor . SceneManagement . EditorSceneManager . IsGameObjectInScene ( volume . gameObject , customScene )
425
+ : UnityEditor . SceneManagement . EditorSceneManager . IsGameObjectInMainScenes ( volume . gameObject ) ;
426
+ #else
427
+ return true ;
428
+ #endif
429
+ }
410
430
}
411
431
}
0 commit comments