- Home /
 
The question is answered, right answer was accepted
How do i adjust terrain texture sizes via script
hi all
I'd like to know how to adjust these X and Y size parameters from a script, at runtime:

I'm also interested in any information/opinions/techniques/anecdotes regarding doing this, and any information about the performance costs.
Answer by Martian-Games · Sep 12, 2015 at 06:09 AM
Click on the Texture asset in your Project folder
In the Inspector, make Texture Type "Advanced"
Check "Read/Write Enabled"
Click "Apply"
Repeat this for all your Terrain textures!
Write C# Script on your Terrain GameObject:
This example changes all x,y Terrain map tileSizes to 100
 Terrain terrain=GetComponent<Terrain>();
 float newTileSize=100f;
 SplatPrototype[] splats=new SplatPrototype[terrain.terrainData.splatPrototypes.Length];
 for(int i=0;i<terrain.terrainData.splatPrototypes.Length;i++){
     SplatPrototype splat=terrain.terrainData.splatPrototypes[i];
     splats[i] = new SplatPrototype(); 
     splats[i].texture = splat.texture;
     splats[i].tileOffset = splat.tileOffset;
     splats[i].tileSize = new Vector2(newTileSize, newTileSize); 
     splats[i].texture.Apply(true);
 }
 terrain.terrainData.splatPrototypes=splats;
 
               Happy Terrain Coding! =oD
Martian Games
Follow this Question
Related Questions
Cant add Terrain Toolkit 0 Answers
Editing Resources files at runtime? 1 Answer
Blend texture seam between 2 terrains tiles 1 Answer
can't resize terrain? 4 Answers
Gather all coordinates of a terrain into a data structure. 1 Answer