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

White backgrounds on headers when using dark theme #1

Closed
instance-id opened this issue Aug 8, 2021 · 1 comment
Closed

White backgrounds on headers when using dark theme #1

instance-id opened this issue Aug 8, 2021 · 1 comment

Comments

@instance-id
Copy link

instance-id commented Aug 8, 2021

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
// -- 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
Copy link
Owner

gasgiant commented Aug 9, 2021

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.

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