Quistar-LAB / PropAnarchy

Prop Anarchy is a mod that utilizes EML and contains popular functions that were rendered incompatible due to the new Prop Framework
MIT License
3 stars 2 forks source link

Blurry icons with Texture Quality set to Medium #5

Open hexabits opened 2 years ago

hexabits commented 2 years ago

This happens with Texture Quality when it is not on High

Blurry This doesn't appear to happen to any other mods' atlas sprites, just Prop/Tree Anarchy's. My friend and I both had this issue, so I investigated it and found that other atlas helpers such as MacSergey's use a different method of loading textures from assembly, and his method appears to have fixed the issue for me:

Fixed

I modified UIIndicator.dll to do this instead:

private static Texture2D LoadTextureFromAssembly(string filename)
{
    Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("UIIndicator.Icons." + filename);
    byte[] array = new byte[manifestResourceStream.Length];
    manifestResourceStream.Read(array, 0, array.Length);
    return new Image(array).CreateTexture(); // Image is from ColossalFramework.Importers
}

This is also an issue for the resources loaded from PropAnarchy assembly: PLT

I applied the same change to LoadTextureFromAssembly in PropAnarchy.dll, but it seems to break the icons (while still fixing the resolution): PLT-fixed

Unfortunately this is because Image().CreateTexture() does not appear to support PNG8, which most of the icons in PropAnarchy.dll are. The PNG images in UIIndicator.dll are PNG32, so they do not have this issue. I've confirmed re-saving the PNG as PNG32 fixes the issue, though I only converted a few.

The PNG8 get loaded into Unity as ARGB32 anyway, so there is not really any benefit other than a few less KBs DLL size. (And the drawback of worse looking colors)

Maybe you can find a way to keep them as PNG8 but fix the resolution issue, if you want. I don't have the original full-color PNG sources nor the UIIndicator repo, so I didn't just make this a pull request.

Also, this doesn't seem to have any relevance or effect on anything, but CreateTextureAtlas in UIIndicator has uitextureAtlas.AddTextures(array); whereas the CreateTextureAtlas in Prop/Tree Anarchy do not.

amirhoseinJ commented 2 years ago

I have the same issue, while the icons are much blurrier.