public void DrawMesh(MeshGenerator.MeshData meshData, Texture2D texture) { GameObject terrainMesh = GameObject.Find("TerrainMesh"); if (terrainMesh == null) { terrainMesh = new GameObject("TerrainMesh"); terrainMesh.AddComponent <MeshFilter>(); terrainMesh.AddComponent <MeshRenderer>(); } _meshFilter = terrainMesh.GetComponent <MeshFilter>(); _meshRenderer = terrainMesh.GetComponent <MeshRenderer>(); _meshFilter.sharedMesh = meshData.CreateMesh(); _meshRenderer.sharedMaterial = _terrainMaterial; _meshRenderer.sharedMaterial.mainTexture = texture; }
public void DrawMesh(MeshGenerator.MeshData meshData, Texture2D texture) { meshFilter.sharedMesh = meshData.CreateMesh(); meshRenderer.sharedMaterial.mainTexture = texture; }