Scripting a gradient?

Is there any way to script a horizontal gradient?

I am currently working in C# script.

I am not skilled to do so, but my guess is a shader that makes a gradient based on texture coordinates (the tex coords function as a tween i guess) for example

There are many ways to do it. Do you want the gradient as a shader or as a texture?

I don’t see why the earlier suggestion in that thread wouldn’t work for this.

http://answers.unity3d.com/questions/27876/shader-needed-for-gradients-using-a-linerenderer/27877#27877

If you need more than a start an end color, with linear blending, then just model your shape and paint its vertex colors in another app, and import that.

I actually want the this gradient as a background to my camera. The script I attached to my camera is C#.

Use another camera using the technique in my link above, and render your main camera using Depth Only as the clear mode. Alternatively, change the shader I wrote there to render in the background queue, with ZWrite Off.

This might be a newbie question, but how can I use vertex colors for this?, I don’t have an actual model in the background. Isn’t there a way to render a gradient based on 2 colors and the height of the screen?

A Line Renderer is probably best. Attach it to a Game Object that also has a camera attached.

You’ll need one. (More precisely, you’ll need a mesh. A Line Renderer is a mesh.)

Sure. I suggest just using a background camera, because then you won’t have to have the Line Renderer dynamically update its position, and it won’t get in the way of anything else you want to render in the Background queue. It will also be really easy to set up positions and widths because you can always have the background camera be orthographic. Marking it as static may be good for performance – but I’m not too knowledgeable at this time about what “Static” does, if anything, aside from with occlusion culling.

I put a script which creates a gradient background on the wiki here.

–Eric