Skip to content

Icons are blocky #1566

Closed
Closed
@SK83RJOSH

Description

@SK83RJOSH

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions