Modify mesh from code without rebuilding it

Good day everyone!

I want to create a mesh from code to make a selection square for an RTS game.
My first version had the problem that OnTriggerEnter was called every Frame because I rebuild the whole mesh.

Is there any way to modify a mesh(created from code) in the Update function without rebuilding the whole mesh.
To modify the vertices doesn´t work, does it?

Or do you know any other way to select units by a rectangle?

Thanks in advance! :slight_smile:

You can change mesh.vertices, just make sure it matches up with mesh.triangles. Another way is to use a canvas, and scale a panel based on your mouse position.
Or use the GL class. Just convert the mouse position to a range of (0,1)
If you use triangles, just make a quad
Just a sample image with a world matrix used