Exemple #1
0
    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;
    }
Exemple #2
0
 public void DrawMesh(MeshGenerator.MeshData meshData, Texture2D texture)
 {
     meshFilter.sharedMesh = meshData.CreateMesh();
     meshRenderer.sharedMaterial.mainTexture = texture;
 }