Okay. I found a solution for this. My solution wasn’t exactly how giulio.pierucci suggested, but it helped my get to the right way. Anyway there is more than one way. What I did was:
(1) Make a quad in the hierarchy
(2) import a perfect white image into the project view.
(3) create a material with the white swatch
(4) drag the material on the quad’s inspector into the mesh renderer Materials property.
(5) create a script file and add code:
MeshFilter viewedModelFilter = (MeshFilter)GetComponent("MeshFilter");
Mesh mesh = viewedModelFilter.mesh;
Color[] colors = new Color[mesh.vertices.Length];
Color BottomColor = Color.red;
Color TopColor = Color.blue;
colors[0] = BottomColor;
colors[1] = TopColor;
colors[2] = BottomColor;
colors[3] = TopColor;
mesh.colors = colors;
into the Update or Start function, depending where you want it.
(6) in the quad’s inspector pick the white material’s shader as Particles/Alpha Blended Premultiply
I’m almost happy with this solution. I have a couple of question though:
(question a) Is this solution efficient or computationally wasteful?
(question b) I’ve added a screen shot. On the left is my Blue to Red gradient in photoshop, on the right is my quad / material gradient in Unity.
Now, when I open the screen shot image in my image editor and use color picker to see the R,G,B values of the respective gradients, I get different colors for unity-sourced gradient vs the editing-sourced gradient, even though they should be exactly the same. The image editor’s gradient is on the left, the unity gradient is on the right. In code I use Color.red/Color.blue, and in the editor I use perfect red (255,0,0) and perfect blue (0,0,255) Why is unity changing the color from perfect red to (248,15,0)-> color-picked, which is almost perfect but not quite. Btw, I also color-picked the screen shot of the original gradient from the editor and the color grab was also not perfect red but different values than the unity-sourced gradient. But shouldn’t the changes the color picker has be exactly identical? Is there a modification in Unity, because of the shader? What can I do to have unity not modify the on-screen colors in that way?
