- Home /
Image Filling To Obtain Color Scale
Hello,
I'm creating 3d visualization in Unity. I have a dropdown with defined equations inside them and every equation is calculated with values from Vector4 (i have a list which has many Vector4 objects). For example:
double equation = (item.x + item.w) / (item.x + item.y + item.z + item.w);
For every result calculated in equation I'm assigning color to that value. For example for 0 it will be blue color, for 1 magenta. How can I fill an image with many colors based on that results? I want to obtain something like this: I've seen similar topic here (https://answers.unity.com/questions/1269593/how-to-create-multi-value-radial-slider.html?childToView=1277778#answer-1277778), but it's about slider filling and I just need an image. Any help would be very appreciated.
you could simply use a texture, marked read/ write enabled. calculate your colors row first into a byte array of width by height length and assign it to the texture via SetPixels
Thanks, your suggestion about texture helped me a lot :) I created new material (I used shader - Particles - Alpha Blended Premultiply) in white color and assigned it to the Quad (I set the width and height to obtain rectangle) . After that I assigned a texture to that material in function in script which I attached to Quad, It's called every time I'm choosing different equation and so I'm recalculating pixels with different colors.