fixed color picker overriding GUI.skin.box.normal.background

This commit is contained in:
2023-03-07 12:18:28 +01:00
parent 3e00d483ef
commit faae081b30

View File

@@ -21,15 +21,15 @@ namespace DevourClient.Helpers
GUI.Label(new Rect(Settings.Settings.x + 300, Settings.Settings.y + 190, 30, 30), "B"); GUI.Label(new Rect(Settings.Settings.x + 300, Settings.Settings.y + 190, 30, 30), "B");
color = new Color(R, G, B, 1); color = new Color(R, G, B, 1);
GUI.color = color;
void DrawPreview(Rect position, Color color_to_draw) void DrawPreview(Rect position, Color color_to_draw)
{ {
Texture2D texture = new Texture2D(1, 1); Texture2D texture = new Texture2D(1, 1);
texture.SetPixel(0, 0, color); texture.SetPixel(0, 0, color_to_draw);
texture.Apply(); texture.Apply();
GUI.skin.box.normal.background = texture; GUIStyle boxStyle = new GUIStyle(GUI.skin.box);
GUI.Box(position, GUIContent.none); boxStyle.normal.background = texture;
GUI.Box(position, GUIContent.none, boxStyle);
} }
DrawPreview(new Rect(Settings.Settings.x + 195, Settings.Settings.y + 100, 20, 90), color); DrawPreview(new Rect(Settings.Settings.x + 195, Settings.Settings.y + 100, 20, 90), color);