Skip to content

Commit

Permalink
Fixed the problem with inability to reach all the GameObjects since U…
Browse files Browse the repository at this point in the history
…nity 5.3 API changes if IncludeDisabledObjects is enabled.
  • Loading branch information
black-square committed Jan 31, 2017
1 parent 18a3c8b commit 5beb133
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 5beb133

Please sign in to comment.