Icons are blocky
SK83RJOSH opened this issue · 1 comments
SK83RJOSH commented
Heya!
I was recently using this package as an example of how to do UI, and in the process I noticed that icons are a bit blocky on 125% DPI. This is down to the filtering used, as well as the size of icon selected. After some testing, I came up with the following patch for my library:
public static Texture2D LoadIcon(string name)
{
var prefix = EditorGUIUtility.isProSkin ? "d_" : "";
var scale = Mathf.CeilToInt(Mathf.Clamp(EditorGUIUtility.pixelsPerPoint, 0, 4));
var suffix = scale > 1 ? $"@{scale}x" : "";
return AssetDatabase.LoadAssetAtPath<Texture2D>(Path.Combine(kIconPath, $"{prefix}{name}{suffix}.png"));
}
This way an icon of a higher resolution is always selected, and when combined with trilinear filtering things look much better, albeit not pixel perfect (which is unachievable with these odder DPI settings anyway). Figured I'd pass this information along since this heavily impacts the Input UI: