public static bool HasConflictingMembers(Type type, IGameObjectDrawer target) { if (type == null) { return(false); } Type[] conflictingTypes; if (!ConflictingTypes.TryGetValue(type, out conflictingTypes)) { return(false); } foreach (var componentDrawer in target) { var memberType = componentDrawer.Type; for (int t = conflictingTypes.Length - 1; t >= 0; t--) { var conflictingType = conflictingTypes[t]; if (conflictingType.IsAssignableFrom(memberType)) { return(true); } } } return(false); }
/// <summary> /// Gets list of existing components drawers on GameObject drawer that prevent component of given type from being added to the target gameobject(s). /// </summary> /// <param name="type"> Component type to check. </param> /// <param name="target"> GameObject drawer. </param> /// <param name="conflictingMembers"> Any found conflicting drawers will be added to this list </param> public static void GetConflictingMembers(Type type, IGameObjectDrawer target, [NotNull] ref List <IComponentDrawer> conflictingMembers) { Type[] conflictingTypes; if (ConflictingTypes.TryGetValue(type, out conflictingTypes)) { foreach (var componentDrawer in target) { var memberType = componentDrawer.Type; for (int t = conflictingTypes.Length - 1; t >= 0; t--) { var conflictingType = conflictingTypes[t]; if (conflictingType.IsAssignableFrom(memberType)) { conflictingMembers.Add(componentDrawer); break; } } } } }