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.GetType(className).GetCustomAttributes(typeof(CustomModifier), false).FirstOrDefault() as CustomModifier; if (attr != null) { return(attr.For); } } return(null); }
public static Dictionary <string, string> GetAttributeClassNameMap(Type targetType) { UnityEngine.Assertions.Assert.IsNotNull(targetType); if (s_attributeClassNameMap == null) { s_attributeClassNameMap = new Dictionary <Type, Dictionary <string, string> >(); } if (!s_attributeClassNameMap.Keys.Contains(targetType)) { var map = new Dictionary <string, string>(); var builders = Assembly .GetExecutingAssembly() .GetTypes() .Where(t => t != typeof(IModifier)) .Where(t => typeof(IModifier).IsAssignableFrom(t)); foreach (var type in builders) { 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.FullName; } else { Debug.LogWarning("Multiple CustomModifier class with the same name/type found. Ignoring " + type.Name); } } } s_attributeClassNameMap[targetType] = map; } return(s_attributeClassNameMap[targetType]); }