IEnumerator DoThings() { Vector3[] initialVerts = new Vector3[_verticies.Length]; while (true) { Vector3[] newVerts = Grid2D.CreateVertices(GridSizeX, GridSizeY, cellSize.x, cellSize.y); float time = 0; float lerpTimeLength = 1f; TerrainModel.JumbleVertz(newVerts, _terrainModel.jumbleAmount); float t = 0; System.Array.Copy(_verticies, initialVerts, _verticies.Length); do { time += Time.deltaTime; t = time / lerpTimeLength; for (int i = 0; i < newVerts.Length; ++i) { _verticies[i] = Vector3.Lerp(initialVerts[i], newVerts[i], t); } Render.DrawVerts(_meshFilter.mesh, _verticies, _tris, _uvs); yield return(null); } while (time <= lerpTimeLength); Render.DrawVerts(_meshFilter.mesh, newVerts, _tris, _uvs); yield return(new WaitForSeconds(2.0f)); } }
void Awake() { InitializeModel(); //int resolution = 256; //Texture2D texture = new Texture2D(resolution, resolution, TextureFormat.RGB24, true); //texture.name = "Procedural Texture"; //GetComponent<MeshRenderer>().material.mainTexture = texture; //Render.FillTexture(resolution, texture); TerrainModel.JumbleVertz(_verticies, jumbleAmount); Render.DrawVerts(_meshFilter.mesh, _verticies, _tris, _uvs); StartCoroutine(DoThings()); }