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); }
private static Dictionary <Type, Dictionary <string, string> > GetAttributeAssemblyQualifiedNameMap() { if (s_attributeAssemblyQualifiedNameMap == null) { s_attributeAssemblyQualifiedNameMap = new Dictionary <Type, 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 builder in allBuilders) { CustomModifier attr = builder.GetCustomAttributes(typeof(CustomModifier), false).FirstOrDefault() as CustomModifier; if (attr != null) { if (!s_attributeAssemblyQualifiedNameMap.ContainsKey(attr.For)) { s_attributeAssemblyQualifiedNameMap[attr.For] = new Dictionary <string, string>(); } var map = s_attributeAssemblyQualifiedNameMap[attr.For]; if (!map.ContainsKey(attr.Name)) { map[attr.Name] = builder.AssemblyQualifiedName; } else { LogUtility.Logger.LogWarning(LogUtility.kTag, "Multiple CustomModifier class with the same name/type found. Ignoring " + builder.Name); } } } } return(s_attributeAssemblyQualifiedNameMap); }