public static string GetModifierGUIName(IModifier m) { CustomModifier attr = m.GetType().GetCustomAttributes(typeof(CustomModifier), false).FirstOrDefault() as CustomModifier; return(attr.Name); }
public static Type GetModifierTargetType(IModifier m) { CustomModifier attr = m.GetType().GetCustomAttributes(typeof(CustomModifier), false).FirstOrDefault() as CustomModifier; UnityEngine.Assertions.Assert.IsNotNull(attr); return(attr.For); }
public static bool HasValidCustomModifierAttribute(Type t) { CustomModifier attr = t.GetCustomAttributes(typeof(CustomModifier), false).FirstOrDefault() as CustomModifier; if (attr != null) { return(!string.IsNullOrEmpty(attr.Name) && attr.For != null); } return(false); }
public static Type GetModifierTargetType(string className) { var type = Type.GetType(className); if (type != null) { CustomModifier attr = type.GetCustomAttributes(typeof(CustomModifier), false).FirstOrDefault() as CustomModifier; if (attr != null) { return(attr.For); } } return(null); }
public static Dictionary <string, string> GetAttributeAssemblyQualifiedNameMap(Type targetType) { UnityEngine.Assertions.Assert.IsNotNull(targetType); if (s_attributeAssemblyQualifiedNameMap == null) { s_attributeAssemblyQualifiedNameMap = new Dictionary <Type, Dictionary <string, string> >(); } if (!s_attributeAssemblyQualifiedNameMap.Keys.Contains(targetType)) { var map = new Dictionary <string, string>(); var allBuilders = new List <Type>(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { var builders = assembly.GetTypes() .Where(t => t != typeof(IModifier)) .Where(t => typeof(IModifier).IsAssignableFrom(t)); allBuilders.AddRange(builders); } foreach (var type in allBuilders) { CustomModifier attr = type.GetCustomAttributes(typeof(CustomModifier), false).FirstOrDefault() as CustomModifier; if (attr != null && attr.For == targetType) { if (!map.ContainsKey(attr.Name)) { map[attr.Name] = type.AssemblyQualifiedName; } else { LogUtility.Logger.LogWarning(LogUtility.kTag, "Multiple CustomModifier class with the same name/type found. Ignoring " + type.Name); } } } s_attributeAssemblyQualifiedNameMap[targetType] = map; } return(s_attributeAssemblyQualifiedNameMap[targetType]); }