x | The x offset to read from. |
y | The y offset to read from. |
width | Ширина альфа карты. |
height | Высота альфа карты. |
float[,,] A 3D array of floats, where the 3rd dimension represents the mixing weight of each splatmap at each x,y coordinate.
Возвращает альфа карту в позиции x,y, учитывая ширину и высоту.
The returned array is three-dimensional - the first two dimensions represent x and y coordinates on the map, while the third denotes the splatmap texture to which the alphamap is applied.
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { // Add some random "noise" to the alphamaps. void AddAlphaNoise(Terrain t, float noiseScale) { float[,,] maps = t.terrainData.GetAlphamaps(0, 0, t.terrainData.alphamapWidth, t.terrainData.alphamapHeight);
for (int y = 0; y < t.terrainData.alphamapHeight; y++) { for (int x = 0; x < t.terrainData.alphamapWidth; x++) { float a0 = maps[x, y, 0]; float a1 = maps[x, y, 1];
a0 += Random.value * noiseScale; a1 += Random.value * noiseScale;
float total = a0 + a1;
maps[x, y, 0] = a0 / total; maps[x, y, 1] = a1 / total; } }
t.terrainData.SetAlphamaps(0, 0, maps); } }