private GameObject CreateGameObject(string name) { Path path = GetComponent <PathCreator>().path; Vector2[] points = path.CalculateEvenlySpacedPoints(spacing); GameObject newGameObject; newGameObject = MeshUtility.Create(name, this.gameObject, typeof(MeshFilter), typeof(MeshRenderer), typeof(Renderer)); newGameObject.isStatic = true; newGameObject.transform.SetParent(transform); Mesh newMesh = CreateMesh(points, path.IsClosed); newGameObject.GetComponent <MeshRenderer>().material = material; newGameObject.GetComponent <MeshFilter>().mesh = newMesh; int textureRepeat = Mathf.RoundToInt(uvTiling * points.Length * spacing * 0.5f); return(newGameObject); }