When creating a lot of objects and trying to give them all a different color after instantiating, unity doesnt really know what to do, it just renders them white.
Using the built in 2d render pipeline. After updating some color values on runtime on a objec the color correcst itself (for example sliding the alpha value).
Trying to pare roud map data from an geoJson file, I wanted to color each dot in the same color which are getting made in the same loop.
#Interesting coloring bug
1 messages · Page 1 of 1 (latest)
The first troubleshooting step for you should be to confirm whether the issue is in your code or rendering
What sticks out to me is that you're setting Color to a high int value, while it's a float from 0 to 1
Color32 would be an int between 0 and 255
did not think that was it because in the inspector the "correct" color was shown but that was the problem
fixed it with diving by the maximum
now I'm getting this
Could do 0 to 1 float randomization to avoid that
Unless you specifically want it to have reduced color depth
was just a quick fix because I didnt wanted to google xD
Or rather because you did change it to floats, you can just change 256 to 1 and it'll work
You also have to remove the division then
1f
like this right
wait
ok that works
oh... before this showed ints as input
that confused me
The documentation page for Random.Range directly has an example for float use, faster than both googling or guessing
It does both floats and ints depending on the variable type
well you get to the documentation page through googeling right?
yea i got that now thanks
It's correct because ints get automatically converted to float (but not vice versa iirc)
👍