public static Color SkinAwareColor(this Color c,bool subtle=false)
        {
            if (EditorGUIUtility.isProSkin)
                return c;
            else
            {

                if (subtle)
                    return Color.Lerp(c, Color.white, 0.7f);
                else
                {
                    if (c == Color.white)
                        return Color.black;
                    else if (c == Color.black)
                        return Color.white;
                    else
                    {
                        float br = c.Brightness();
                        if (br > 0.9)
                            return Color.Lerp(c, Color.black, 0.7f);
                        else
                            return Color.Lerp(c, Color.black, 0.2f);
                    }
                }
            }
        }
Beispiel #2
0
		/**
			Returns a new color with the RGB values scaled so that the color 
			has the given brightness. 

			If the color is too dark, a grey is returned with the right brighness.

			The alpha is left uncanged.
		*/
		public static Color WithBrightness(this Color color, float brightness)
		{
			if (color.IsApproximatelyBlack())
			{
				return new Color(brightness, brightness, brightness, color.a);
			}
			
			float factor = brightness/color.Brightness();

			float r = color.r*factor;
			float g = color.g*factor;
			float b = color.b*factor;

			float a = color.a;

			return new Color(r, g, b, a);
		}