动态更换地形纹理图

更改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()
	{
	
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值