首页 > 其他分享 >36. 更换unity terrain的地表贴图

36. 更换unity terrain的地表贴图

时间:2022-11-24 00:01:27浏览次数:64  
标签:贴图 map point int terrain 36 terrainData

设置alphamap的核心方法是TerrainData的SetAlphamaps方法,关键参数是alpha三维数组。它的前两维表示了splatmap的大小,最后一维表示layer数目,也就是所使用的splatmap的通道数

using UnityEngine;

public class Example : MonoBehaviour { public Terrain t; // Blend the two terrain textures according to the steepness of // the slope at each point. void Start() { float[,,] map = new float[t.terrainData.alphamapWidth, t.terrainData.alphamapHeight, 2];

// For each point on the alphamap... for (int y = 0; y < t.terrainData.alphamapHeight; y++) { for (int x = 0; x < t.terrainData.alphamapWidth; x++) { map[x, y, 0] = 0; map[x, y, 1] = 1; } } t.terrainData.SetAlphamaps(0, 0, map); } }

标签:贴图,map,point,int,terrain,36,terrainData
From: https://www.cnblogs.com/dandansang/p/16920572.html

相关文章