Hi, I am creating my own “button look” without using texture files,
and I’m struggling with their display (Unity Editor Custom Window) with incorrect color values.
They seems to be multiplied by some factor (maybe darken unity Editor skin color ?), and I can’t find a way to retrieve my exact colors.
Here are a snippet of what I am doing, simplified of course.
I am using a picker to pick a color, and then the button that should be drawn with it has another color.
Thanks for any help on this !
On a GUIMultiplyEffect_EditorWindow.cs file :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class GUIMultiplyEffect_EditorWindow :EditorWindow
{
Color buttonColor = Color.gray;
[MenuItem("Window/GUIMultiply : EditorWindow", false, 42)]
public static void ShowWindow()
{
EditorWindow.GetWindow(typeof(GUIMultiplyEffect_EditorWindow));
}
void OnGUI()
{
buttonColor = EditorGUILayout.ColorField(buttonColor);
GUIStyle customButtonStyle = new GUIStyle(GUI.skin.button);
Texture2D customBackgroundTexture = new Texture2D(2, 2);
customBackgroundTexture.SetPixels(new Color[4] { buttonColor, buttonColor, buttonColor, buttonColor });
customBackgroundTexture.Apply();
customButtonStyle.normal.background = customBackgroundTexture;
if (GUILayout.Button("My Button", customButtonStyle))
{
}
}
}