public static IEnumerable <IRegistry> GetRegistries(IComponent component) { if (component == null) { throw new ArgumentNullException(nameof(component)); } foreach (var componentType in ComponentTypeUtility.GetManagedComponentTypes(component.GetType())) { yield return(GetRegistry(componentType)); } }
private static IEnumerable <Type> FetchRequiredComponentTypes(Type componentType) { if (!typeof(Component).IsAssignableFrom(componentType)) { throw new ArgumentException("Component type is not derived from component.", nameof(componentType)); } foreach (var type in ComponentTypeUtility.GetManagedComponentTypes(componentType)) { foreach (var attribute in type.GetCustomAttributes(typeof(RuntimeRequireComponentAttribute), true).Cast <RuntimeRequireComponentAttribute>()) { var requiredComponentType = attribute.componentType; if (!typeof(Component).IsAssignableFrom(requiredComponentType)) { Debug.LogWarning($"Required component type '{requiredComponentType}' is not derived from component, ignoring."); continue; } yield return(requiredComponentType); } } }