Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icons are blocky #1566

Closed
SK83RJOSH opened this issue Jul 26, 2022 · 1 comment
Closed

Icons are blocky #1566

SK83RJOSH opened this issue Jul 26, 2022 · 1 comment

Comments

@SK83RJOSH
Copy link

SK83RJOSH commented Jul 26, 2022

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:

image

@andrew-oc
Copy link
Contributor

Hi there, thanks for reporting this, but as per #1172, please use the Unity bug reporter or the forums for reporting issues. This issue will now be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants