- Home /
How to initialize a Color array to a key color, once in code hit frequently.
I'm setting up a color array to use for checking another color variable against it. Since color isn't nullable in Unity, I'm trying to do is initialize it to a key color. (Which is never used in game) From there I set it to the initial value of the color to check against here once, and only once. After that in another method if the two values don't match up I return false. How should I go about replacing the false
with an actual value?
Here's the code in question:
private static Color[] initializePrevColor(Color[] prevColorToCheck, Color[] tileColorToCheck)
{
for (int i = 0; i < prevColorToCheck.Length; i++)
{
if (false)
{
prevColorToCheck[i] = Color.white;
}
if (prevColorToCheck[i] != tileColorToCheck[i]
&& prevColorToCheck[i] == Color.white)
prevColorToCheck[i] = tileColorToCheck[i];
}
return prevColorToCheck;
}
Comment
I ended up resorting to using a bool as a flag. If there is a more elegant means of doing this I would love to know.
Your answer
Follow this Question
Related Questions
color in textmesh 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Change the color of the string 2 Answers