- Home /
How to generate a complete terrain via Script
Hi.
I'm trying to create a basic game in which you have different maps. I would like to allow the player to have its own maps. Here is ho i plan to do this : A map file is a basic archive containing :
- The height map 
- The texture map 
The height map can be easily generated by TerrainData.SetHeights() from a matrice containing heights. But. How to set the texture of a Terrain from a point ? I'd like to do something like :
 // Open file, read file, split to get rows, re-split to get a 2D array of heights.
 float[][] heights = fileToHeihgts(filepath);
 
 // Open file, read file, split to get rows, re-split to get a 2D array of string,
 // and use Resources.LoadAssetAtPath to load texture from string.
 Texture[][] textures = fileToTexture(filepath);
 
 TerrainData tData = new TerrainData();
 tData.SetHeight(0, 0, heights);
 tData.SetTextures(0, 0, textures); 
But i don't see any way to do "SetTextures". I saw a guy who created one terrain by texture, and set alphamaps to each of them (each point (x,y) has only one terrain visible). Is there another way ?
Thanks.
You have to use TerrainData.detailPrototypes and DetailPrototype.prototypeTexture to play with terrain textures at runtime.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                