How do I change the colour of a part of a mesh between vertices?

How would I make a certain part of my mesh a different material without using a new mesh?
I would like one single tile in the grid to be gray but I’m unsure how to do that.
Thank you.


If you are not familiar with meshes, i would recommend this page: Unity - Scripting API: Mesh

There are basically two options:

  • Set mesh.colors in a way that every tile will be a color you want,
  • Set mesh.uv in a way that the texture laid on it will cover every tile with the color you want.

The first option can get a bit tricky, since the color between the vertices is interpolated, so you can only have a color gradient with this setup, unless you double every vertex that is not on the corners.

For the second option, you will need to procedurally create a new texture every time you want to make changes to the colors, and assign that to your mesh. If your UV layout is correct, the bottom left corner UV will be (0,0), and the top right corner UV will be (1,1). Be sure to use a 11x11 texture and set the filtering mode to Point filter.

Id like a tile’s colour to change when clicked on, is there a way to change a single tile and not every part of the mesh? Like this when it’s clicked