更改terrain地形中的纹理贴图,代码如下:
public class TerrainTextureAssigner : MonoBehaviour
{
public Texture2D[] TerrainTextures;//更换的纹理贴图
public Texture2D[] PingChangTerrainTextures;//原纹理图
private SplatPrototype[] oriPrototypes;
private SplatPrototype[] newPrototypes;
public Material mat;//地形的材质球
private TerrainData terraindata;
public Terrain terrain;
private bool isIR = false;
public void CreateTerrain(){
newPrototypes = new SplatPrototype [TerrainTextures.Length];
for (int i=0; i<TerrainTextures.Length; i++) {
newPrototypes [i] = new SplatPrototype ();
//newPrototypes [i] = oriPrototypes [i];
newPrototypes [i].texture = TerrainTextures [i]; //Sets the texture
newPrototypes [i].texture.filterMode = FilterMode.Point;
newPrototypes [i].normalMap = oriPrototypes[i].normalMap;
newPrototypes [i].tileSize = oriPrototypes[i].tileSize; //Sets the size of the texture
}
}
void Start()
{