What is the best way to go about manipulating vertices?

For example, changing color (for simplicity).

Sometimes I find myself trying to distinguish between whether to write a script, or whether to write/edit a shader. For example, let's say I have a simple primitive, like a sphere. I want all of the vertices to be green. It seems to me that there are two possible approaches:

  1. Write a script that loops through all of the vertices of a Mesh (in the Update function) and change the color to Color.green, or

  2. Write a shader that simply sets the Main Color to green.

Obviously, two is the better choice. Although, I think that #1 also depends on the shader, since not all shaders will respond to vertex-color changes.

But if the question gets more complex, i.e., I'd like to implement some fractal and noise functions. How do I know what I should accomplish in a script, and then what I should do with the shader?

Hope this makes sense. If not, just say so and I'll try to reword it.

Cheers.

Good question...persistance, perhaps? If you want to change something about a mesh permanently (like applying damage to a car model), it seems to me that changing the mesh in a script is more appropriate. A shader would be better for something where you have a basic state that has an effect applied "on top" of that every frame (like a waving flag shader). You could do that with a script too, but a shader would be faster and use fewer resources.