- Home /
Strange unity color bug
I just got a hold of the free version of the A* pathfinding project, and unity is giving me 9 errors saying that the Color constructor doesn't take 4 arguments. Has something changed recently, last I checked color took arguments for red, green, blue, and alpha.
Answer by Jamora · Aug 09, 2013 at 08:32 AM
You left out a crucial piece of information: the type are the arguments you are trying to provide. Had you posted the error message in its entirety I would have been sure...
I'm going to take a stab in the dark here: You're trying to provide ints or doubles to the Color constructor, while it only accepts floats. Remember that floats take the f at the end (1f, 0.5f) in C#.
The components of Color need to be in the inclusive range [0,1].
Nope, _$$anonymous$$eshColor = new Color (0.125F, 0.686F, 0.0F, 0.19F); And I still get errors from it
Also Unity fails to register individual colors. For example _$$anonymous$$eshColor.r returns an error as does Color.white.
Ok it seems to clear up when I use UnityEngine.Color, I think it's a conflict between the base definition of c#'s library and the unity library.
Are you putting this at the top of your code?
using UnityEngine;
Answer by melkior · Feb 15, 2015 at 07:02 PM
I just wanted to post that the using UnityEngine.Color is what works for me as well; I do think there's some namespace conflict between unity and mono as of the updates that came recently
Example: private static UnityEngine.Color white = new UnityEngine.Color(1, 1, 1, 1);
Works fine.
NON-Working example that used to work:
private static Color = Color.white;
Your answer
![](https://koobas.hobune.stream/wayback/20220613111823im_/https://answers.unity.com/themes/thub/images/avi.jpg)