gasgiant / Markup-Attributes

A Unity Editor extension for customizing inspector layout with attributes.
MIT License
289 stars 11 forks source link

White backgrounds on headers when using dark theme #1

Closed instance-id closed 3 years ago

instance-id commented 3 years ago

Hey there, At least in 2020.3, when using the dark theme, these headers (and all similar ones) show up as white:

I implemented a small change locally so I could make it adjustable.

Details ```cs // -- ExtraEditorStyles.cs public static class ExtraEditorStyles { // -- Added a few colors ----- private static Color darkColor = new Color(0.18f, 0.18f, 0.18f); private static Color lightColor = new Color(1f, 1f, 1f, 1f); ... private static GUIStyle CreateBoxStyle(Texture2D texture) { var style = new GUIStyle(EditorStyles.helpBox); // -- Color determination ----- style.normal.background = EditorGUIUtility.isProSkin ? ColoredTexture(darkColor) : ColoredTexture(lightColor); if (texture != null) style.normal.scaledBackgrounds = new Texture2D[] { texture }; return style; } ... // -- Added new static method ----- private static Texture2D ColoredTexture(Color color) { int w = 4, h = 4; Texture2D back = new Texture2D(w, h); Color[] buffer = new Color[w * h]; for (int i = 0; i < w; ++i) for (int j = 0; j < h; ++j) buffer[i + w * j] = color; back.SetPixels(buffer); back.Apply(false); return back; } ```

Which then made it a bit nicer to look at:

It is probably not the best way to go about it, performance-wise, but you get the idea.
Thanks,

gasgiant commented 3 years ago

Hi! Thanks for pointing this out. Fixed the problem.

I work on a scailed screen and didn't assign the proper texture for the unscaled background. I am a bit fuzzy on how all this works in IMGUI, to be honest. There is a slight inconsistency between how the corners of the headers look in scaled and unscaled modes, but it's very minor and looks fine either way. I'll fix this inclonsistency later.