Created
June 11, 2018 09:05
-
-
Save glitchersgames/c1d33a635fa0ca76e38de0591bb1b798 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.SceneManagement; | |
namespace Glitchers | |
{ | |
public static class FindInterfaces | |
{ | |
public static List<T> Find<T>( ) | |
{ | |
List<T> interfaces = new List<T>(); | |
GameObject[] rootGameObjects = SceneManager.GetActiveScene().GetRootGameObjects(); | |
foreach( var rootGameObject in rootGameObjects ) | |
{ | |
T[] childrenInterfaces = rootGameObject.GetComponentsInChildren<T>(); | |
foreach( var childInterface in childrenInterfaces ) | |
{ | |
interfaces.Add(childInterface); | |
} | |
} | |
return interfaces; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment