Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions com.unity.render-pipelines.core/Runtime/BatchRenderer/RenderBRG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@ public void Destroy()

public class RenderBRG : MonoBehaviour
{
private static bool s_QueryLoadedScenes = true;
private Dictionary<Scene, SceneBRG> m_Scenes = new();

private void OnEnable()
Expand All @@ -805,6 +806,17 @@ private void OnEnable()
SceneManager.sceneUnloaded += OnSceneUnloaded;

List<Scene> toAdd = new List<Scene>();

//During play mode, if we reload the render pipeline, this will help during restart to reparse any previously loaded scenes.
if (s_QueryLoadedScenes)
{
for (int s = 0; s < SceneManager.sceneCount; ++s)
{
toAdd.Add(SceneManager.GetSceneAt(s));
}
s_QueryLoadedScenes = false;
}

foreach (var sceneBrg in m_Scenes)
{
if (sceneBrg.Value == null)
Expand Down Expand Up @@ -851,6 +863,9 @@ private static void GetValidChildRenderers(GameObject root, List<MeshRenderer> t

private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (m_Scenes.TryGetValue(scene, out var existingBRG) && existingBRG != null)
return;

var renderers = new List<MeshRenderer>();
foreach (var go in scene.GetRootGameObjects())
GetValidChildRenderers(go, renderers);
Expand Down