Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit dee1d8c

Browse files
committed
2018.3 scene view fix
1 parent fcdb350 commit dee1d8c

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

PostProcessing/Runtime/PostProcessLayer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ void UpdateSettingsIfNeeded(PostProcessRenderContext context)
580580
if (m_SettingsUpdateNeeded)
581581
{
582582
context.command.BeginSample("VolumeBlending");
583-
PostProcessManager.instance.UpdateSettings(this);
583+
PostProcessManager.instance.UpdateSettings(this, context.camera);
584584
context.command.EndSample("VolumeBlending");
585585
m_TargetPool.Reset();
586586

PostProcessing/Runtime/PostProcessManager.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ void ReplaceData(PostProcessLayer postProcessLayer)
278278
}
279279
}
280280

281-
internal void UpdateSettings(PostProcessLayer postProcessLayer)
281+
internal void UpdateSettings(PostProcessLayer postProcessLayer, Camera camera)
282282
{
283283
// Reset to base state
284284
ReplaceData(postProcessLayer);
@@ -295,6 +295,12 @@ internal void UpdateSettings(PostProcessLayer postProcessLayer)
295295
// Traverse all volumes
296296
foreach (var volume in volumes)
297297
{
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+
298304
// Skip disabled volumes and volumes without any data or weight
299305
if (!volume.enabled || volume.profileRef == null || volume.weight <= 0f)
300306
continue;
@@ -407,5 +413,19 @@ static void SortByPriority(List<PostProcessVolume> volumes)
407413
volumes[j + 1] = temp;
408414
}
409415
}
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+
}
410430
}
411431
}

0 commit comments

Comments
 (0)