///Get icon from [IconAttribute] info public static Texture GetTypeIcon(IconAttribute iconAttribute, object instance = null) { if (iconAttribute == null) { return(null); } if (instance != null && !string.IsNullOrEmpty(iconAttribute.runtimeIconTypeCallback)) { var callbackMethod = instance.GetType().RTGetMethod(iconAttribute.runtimeIconTypeCallback); return(callbackMethod != null && callbackMethod.ReturnType == typeof(Type) ? GetTypeIcon((Type)callbackMethod.Invoke(instance, null), false) : null); } if (iconAttribute.fromType != null) { return(GetTypeIcon(iconAttribute.fromType, true)); } Texture texture = null; if (typeIcons.TryGetValue(iconAttribute.iconName, out texture)) { return(texture); } if (!string.IsNullOrEmpty(iconAttribute.iconName)) { texture = Resources.Load <Texture>(EXPLICIT_ICONS_PATH + iconAttribute.iconName); if (texture == null) //for user made icons where user don't have to know the path { texture = Resources.Load <Texture>(iconAttribute.iconName); } } return(typeIcons[iconAttribute.iconName] = texture); }
///Get icon from [IconAttribute] info public static Texture GetTypeIcon(IconAttribute iconAttribute, object instance = null) { if (iconAttribute == null) { return(null); } if (instance != null && !string.IsNullOrEmpty(iconAttribute.runtimeIconTypeCallback)) { var callbackMethod = instance.GetType().RTGetMethod(iconAttribute.runtimeIconTypeCallback); return(callbackMethod != null && callbackMethod.ReturnType == typeof(Type)? GetTypeIcon((Type)callbackMethod.Invoke(instance, null), false) : null); } Texture texture = null; if (typeIcons.TryGetValue(iconAttribute.iconName, out texture)) { return(texture); } texture = !string.IsNullOrEmpty(iconAttribute.iconName)? Resources.Load <Texture>(iconAttribute.iconName) : null; return(typeIcons[iconAttribute.iconName] = texture); }