Skip to content

Commit

Permalink
fix(SharedMethods): don't search in unloaded scenes
Browse files Browse the repository at this point in the history
Change scene searches to not look in scenes that are open in the editor
but not loaded.
  • Loading branch information
jamre committed Sep 6, 2018
1 parent f5b30c8 commit 2a21238
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Assets/VRTK/Source/Scripts/Utilities/VRTK_SharedMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -789,13 +789,13 @@ private static IEnumerable<T> FindEvenInactiveComponentsInValidScenes<T>(bool se
List<T> allSceneResults = new List<T>();
for (int sceneIndex = 0; sceneIndex < SceneManager.sceneCount; sceneIndex++)
{
allSceneResults.AddRange(FindEventInactiveComponentsInScene<T>(SceneManager.GetSceneAt(sceneIndex), stopOnMatch));
allSceneResults.AddRange(FindEvenInactiveComponentsInScene<T>(SceneManager.GetSceneAt(sceneIndex), stopOnMatch));
}
results = allSceneResults;
}
else
{
results = FindEventInactiveComponentsInScene<T>(SceneManager.GetActiveScene(), stopOnMatch);
results = FindEvenInactiveComponentsInScene<T>(SceneManager.GetActiveScene(), stopOnMatch);
}

return results;
Expand All @@ -807,9 +807,14 @@ private static IEnumerable<T> FindEvenInactiveComponentsInValidScenes<T>(bool se
/// <param name="scene">The scene to search. This scene must be valid, either loaded or loading.</param>
/// <param name="stopOnMatch">If true, will stop searching objects as soon as a match is found.</param>
/// <returns></returns>
private static IEnumerable<T> FindEventInactiveComponentsInScene<T>(Scene scene, bool stopOnMatch = false)
private static IEnumerable<T> FindEvenInactiveComponentsInScene<T>(Scene scene, bool stopOnMatch = false)
{
List<T> results = new List<T>();
if(!scene.isLoaded)
{
return results;
}

foreach (GameObject rootObject in scene.GetRootGameObjects())
{
if (stopOnMatch)
Expand Down

0 comments on commit 2a21238

Please sign in to comment.