using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; namespace Rokojori { public static class SceneExtensions { public static T Get( this Scene scene ) { var roots = scene.GetRootGameObjects(); for ( int i = 0; i < roots.Length; i++ ) { var t = roots[ i ].GetComponentInChildren(); if ( t != null ) { return t; } } return default(T); } public static T GetInOpenScenes() { var numScenes = SceneManager.sceneCount; for ( int i = 0; i < numScenes; i++ ) { var scene = SceneManager.GetSceneAt( i ); var obj = scene.Get(); if ( obj != null ) { return obj; } } return default(T); } } }