Color is white in inspector
Asked Answered
C

2

0

I have a few inspector fields in my C# code:

public Color BackgroundColor = new Color(45, 50, 125, 255);
public Color TextColor = new Color(228, 228, 228, 255);
public Color WarningColor = new Color(254, 213, 0, 255);
public Color ErrorColor = new Color(241, 74, 36, 255);

But when I add my script to a component all the colors are white except for the yellow.
I tried to reset the colors in the Reset method but that doesn’t work either, they stay white until I change them in unity.

Can this be fixed, does someone know why this happens?

Companionate answered 12/6 at 20:44 Comment(0)
I
0

Check this:

The problem probably occurs cause you are using the range from 0 to 255, but Unity works with 0 to 1.

Ilium answered 12/6 at 20:45 Comment(1)

Don't forget to set the topic answered. =D

Frye
T
0

Color32 though accepts values from 0 to 255, so that would work:

public Color BackgroundColor = new Color32(45, 50, 125, 255);
Tartlet answered 12/6 at 20:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.