mesh having a tile effect?

The problem is that the size is always random, and the floor material gets stretched, how can i make it so it has a tile effect, even if the floor looks like a rhombus or a rectangle etc.

this is my code so far.

var floor = new GameObject("floor");
floor.AddComponent(MeshFilter);
floor.AddComponent(MeshRenderer);
//floor.AddComponent(MeshCollider);
var floorMesh = new Mesh();
floorMesh.name = "floorMesh";
floorMesh.vertices = [V1, V2, V3, V4];
floorMesh.triangles = [0, 1, 2, 0, 2, 3, 0, 2, 1, 0, 3, 2];
floorMesh.normals = [Vector3.up,Vector3.up,Vector3.up,Vector3.up];
floorMesh.uv = [Vector2(0,1),Vector2(0,0),Vector2(1,0),Vector2(1,1)];

//floor.GetComponent(MeshCollider).sharedMesh = meshToCollide;
floor.GetComponent(MeshFilter).mesh = floorMesh;

//current color is a material, i get an error what i put a texture.

floor.GetComponent(MeshRenderer).material = currentColor;
floor.AddComponent(MeshCollider);
floor.transform.parent = floorParent.transform;

Size is random? Where are V1 through V4 defined?

You'd have to do some math to get the correct UV's depending on the shape. Google for uv planar mapping code. Good luck