Skip to content

Commit

Permalink
Merge pull request #18 from black-square/bugfix/CannotReachAllTheOBjects
Browse files Browse the repository at this point in the history
Fixed the problem with inability to reach all the GameObjects since Unity 5.3 API changes if IncludeDisabledObjects is enabled
  • Loading branch information
HandCircus committed Feb 3, 2017
2 parents 18a3c8b + 5beb133 commit 6e2448d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ResourceChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -926,11 +926,24 @@ void CheckResources()
collectedInPlayingMode = Application.isPlaying;
}

private static GameObject[] GetAllRootGameObjects()
{
#if !UNITY_5_3_OR_NEWER
return UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects().ToArray();
#else
List<GameObject> allGo = new List<GameObject>();
for (int sceneIdx = 0; sceneIdx < UnityEngine.SceneManagement.SceneManager.sceneCount; ++sceneIdx){
allGo.AddRange( UnityEngine.SceneManagement.SceneManager.GetSceneAt(sceneIdx).GetRootGameObjects().ToArray() );
}
return allGo.ToArray();
#endif
}

private T[] FindObjects<T>() where T : Object
{
if (IncludeDisabledObjects) {
List<T> meshfilters = new List<T> ();
GameObject[] allGo = UnityEngine.SceneManagement.SceneManager.GetActiveScene ().GetRootGameObjects ().ToArray ();
GameObject[] allGo = GetAllRootGameObjects();
foreach (GameObject go in allGo) {
Transform[] tgo = go.GetComponentsInChildren<Transform> (true).ToArray ();
foreach (Transform tr in tgo) {
Expand Down

0 comments on commit 6e2448d

Please sign in to comment.