public List <MonoBehaviour> FindReference(CustomEvent e) { List <MonoBehaviour> result = new List <MonoBehaviour>(); for (int i = 0; i < SceneManager.sceneCount; i++) { var scene = SceneManager.GetSceneAt(i); var allObjects = scene.GetRootGameObjects(); for (int j = 0; j < allObjects.Length; j++) { var obj = allObjects[j]; var comps = obj.GetComponentsInChildren <MonoBehaviour>(true); foreach (var comp in comps) { FieldInfo[] fields = comp.GetType().GetFields(); foreach (var field in fields) { KAIEvent attrib = Attribute.GetCustomAttribute(field, typeof(KAIEvent)) as KAIEvent; if (attrib != null) { if (field.GetValue(comp) as CustomEvent != null && (field.GetValue(comp) as CustomEvent).name.Equals(e.name)) { result.Add(comp); } } } } } } return(result); }
public EventData(string name, CustomEvent e) { Name = name; Event = e; }