Skip to content

Commit 2a21238

Browse files
committed
fix(SharedMethods): don't search in unloaded scenes
Change scene searches to not look in scenes that are open in the editor but not loaded.
1 parent f5b30c8 commit 2a21238

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Assets/VRTK/Source/Scripts/Utilities/VRTK_SharedMethods.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -789,13 +789,13 @@ private static IEnumerable<T> FindEvenInactiveComponentsInValidScenes<T>(bool se
789789
List<T> allSceneResults = new List<T>();
790790
for (int sceneIndex = 0; sceneIndex < SceneManager.sceneCount; sceneIndex++)
791791
{
792-
allSceneResults.AddRange(FindEventInactiveComponentsInScene<T>(SceneManager.GetSceneAt(sceneIndex), stopOnMatch));
792+
allSceneResults.AddRange(FindEvenInactiveComponentsInScene<T>(SceneManager.GetSceneAt(sceneIndex), stopOnMatch));
793793
}
794794
results = allSceneResults;
795795
}
796796
else
797797
{
798-
results = FindEventInactiveComponentsInScene<T>(SceneManager.GetActiveScene(), stopOnMatch);
798+
results = FindEvenInactiveComponentsInScene<T>(SceneManager.GetActiveScene(), stopOnMatch);
799799
}
800800

801801
return results;
@@ -807,9 +807,14 @@ private static IEnumerable<T> FindEvenInactiveComponentsInValidScenes<T>(bool se
807807
/// <param name="scene">The scene to search. This scene must be valid, either loaded or loading.</param>
808808
/// <param name="stopOnMatch">If true, will stop searching objects as soon as a match is found.</param>
809809
/// <returns></returns>
810-
private static IEnumerable<T> FindEventInactiveComponentsInScene<T>(Scene scene, bool stopOnMatch = false)
810+
private static IEnumerable<T> FindEvenInactiveComponentsInScene<T>(Scene scene, bool stopOnMatch = false)
811811
{
812812
List<T> results = new List<T>();
813+
if(!scene.isLoaded)
814+
{
815+
return results;
816+
}
817+
813818
foreach (GameObject rootObject in scene.GetRootGameObjects())
814819
{
815820
if (stopOnMatch)

0 commit comments

Comments
 (0)