internal Dictionary <string, byte[]> GenerateDrawableResourcesForExport() { var icons = new Dictionary <string, byte[]>(); foreach (var res in TrackedResourceAssets) { if (!res.Verify()) { Debug.LogWarning(string.Format("Failed exporting: '{0}' AndroidSettings notification icon because:\n {1} ", res.Id, DrawableResourceData.GenerateErrorString(res.Errors)) ); continue; } var texture = TextureAssetUtils.ProcessTextureForType(res.Asset, res.Type); var scale = res.Type == NotificationIconType.SmallIcon ? 0.375f : 1; var textXhdpi = TextureAssetUtils.ScaleTexture(texture, (int)(128 * scale), (int)(128 * scale)); var textHdpi = TextureAssetUtils.ScaleTexture(texture, (int)(96 * scale), (int)(96 * scale)); var textMdpi = TextureAssetUtils.ScaleTexture(texture, (int)(64 * scale), (int)(64 * scale)); var textLdpi = TextureAssetUtils.ScaleTexture(texture, (int)(48 * scale), (int)(48 * scale)); icons[string.Format("drawable-xhdpi-v11/{0}.png", res.Id)] = textXhdpi.EncodeToPNG(); icons[string.Format("drawable-hdpi-v11/{0}.png", res.Id)] = textHdpi.EncodeToPNG(); icons[string.Format("drawable-mdpi-v11/{0}.png", res.Id)] = textMdpi.EncodeToPNG(); icons[string.Format("drawable-ldpi-v11/{0}.png", res.Id)] = textLdpi.EncodeToPNG(); if (res.Type == NotificationIconType.LargeIcon) { var textXxhdpi = TextureAssetUtils.ScaleTexture(texture, (int)(192 * scale), (int)(192 * scale)); icons[string.Format("drawable-xxhdpi-v11/{0}.png", res.Id)] = textXxhdpi.EncodeToPNG(); } } return(icons); }
public static Texture2D ProcessAndResizeTextureForType(Texture2D texture, NotificationIconType type, ImageSize size) { var width = 0; var height = 0; var scale = type == NotificationIconType.SmallIcon ? 0.375f : 1; if (size == ImageSize.XXHDPI) { width = (int)(192 * scale); height = (int)(192 * scale); } else if (size == ImageSize.XHDPI) { width = (int)(128 * scale); height = (int)(128 * scale); } else if (size == ImageSize.HDPI) { width = (int)(96 * scale); height = (int)(96 * scale); } else if (size == ImageSize.MDPI) { width = (int)(64 * scale); height = (int)(64 * scale); } else if (size == ImageSize.LDPI) { width = (int)(48 * scale); height = (int)(48 * scale); } var downscaled = TextureAssetUtils.ScaleTexture(texture, width, height); return(TextureAssetUtils.ProcessTextureForType(downscaled, type)); }