public class TerrainDetailControl : MonoBehaviour {
public GameObject terrain;
public Texture2D[] texx;//要更换为的贴图
private List<Texture2D> detailsGameobject = new List<Texture2D>();
private DetailPrototype[] newPrototypes;
private DetailPrototype[] oriPrototypes;
private bool isIR = false;
// Use this for initialization
void Start () {
oriPrototypes = Terrain.activeTerrain.terrainData.detailPrototypes;//记录当前TerrainDetail的贴图
newPrototypes = new DetailPrototype [texx.Length];
for (int i = 0; i < texx.Length; i++) {
newPrototypes [i] = new DetailPrototype ();
newPrototypes [i].prototypeTexture = texx[i];
newPrototypes [i].prototype = oriPrototypes[i].prototype;
newPrototypes [i].maxHeight = oriPrototypes[i].maxHeight;
newPrototypes [i].maxWidth = oriPrototypes[i].maxWidth;
newPrototypes [i].minHeight = oriPrototypes[i].minHeight;
newPrototypes [i].minWidth = oriPrototypes[i].minWidth;
newProto
动态更改TerrainDetail的贴图
最新推荐文章于 2023-07-21 11:05:06 发布