本文整理汇总了C#中UnityEngine.Terrain.SetNeighbors方法的典型用法代码示例。如果您正苦于以下问题:C# Terrain.SetNeighbors方法的具体用法?C# Terrain.SetNeighbors怎么用?C# Terrain.SetNeighbors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Terrain
的用法示例。
在下文中一共展示了Terrain.SetNeighbors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
R = Instantiate(MainTerrain) as Terrain;
R.transform.position = new Vector3(MainTerrain.terrainData.size.x,0,0);
L = Instantiate(MainTerrain) as Terrain;
L.transform.position = new Vector3(-MainTerrain.terrainData.size.x,0,0);
T = Instantiate(MainTerrain) as Terrain;
T.transform.position = new Vector3(0,0,MainTerrain.terrainData.size.z);
B = Instantiate(MainTerrain) as Terrain;
B.transform.position = new Vector3(0,0,-MainTerrain.terrainData.size.z);
TR = Instantiate(MainTerrain) as Terrain;
TR.transform.position = new Vector3(MainTerrain.terrainData.size.x,0,MainTerrain.terrainData.size.z);
BR = Instantiate(MainTerrain) as Terrain;
BR.transform.position = new Vector3(MainTerrain.terrainData.size.x,0,-MainTerrain.terrainData.size.z);
TL = Instantiate(MainTerrain) as Terrain;
TL.transform.position = new Vector3(-MainTerrain.terrainData.size.x,0,MainTerrain.terrainData.size.z);
BL = Instantiate(MainTerrain) as Terrain;
BL.transform.position = new Vector3(-MainTerrain.terrainData.size.x,0,-MainTerrain.terrainData.size.z);
TL.SetNeighbors(null,null,T,L);
T.SetNeighbors(TL,null,TR,MainTerrain);
TR.SetNeighbors(T,null,null,R);
L.SetNeighbors(null,TL,MainTerrain,BL);
MainTerrain.SetNeighbors(L,T,R,B);
R.SetNeighbors(MainTerrain,TR,null,BR);
BL.SetNeighbors(null,L,B,null);
B.SetNeighbors(BL,MainTerrain,BR,null);
BR.SetNeighbors(B,R,null,null);
}
示例2: GenerateTerrainBaseShapeCoroutine
public IEnumerator GenerateTerrainBaseShapeCoroutine(Terrain terrain, float xOffset, int numberOfHills, int maxRadius, int minRadius)
{
print("Generuje");
TerrainData data = terrain.terrainData;
float[,] heightMap = new float[terrain.terrainData.heightmapWidth, terrain.terrainData.heightmapHeight];
float xVal = 0.0f;
for (int i = 0; i < terrain.terrainData.heightmapWidth; i++) {
for (int j = 0; j < terrain.terrainData.heightmapHeight; j++) {
xVal = ((float)i / (float)data.heightmapWidth) * perlinNoiseDensity;
float yVal = ((float)j / (float)data.heightmapHeight) * perlinNoiseDensity;
heightMap[i, j] = Mathf.PerlinNoise(xVal + xOffset, yVal) / perlinNoiseDivider;
}
}
nextOffset += xVal;
for (int i = 0; i < numberOfHills; i++) {
int radius = Random.Range(minRadius, maxRadius);
int randX = Random.Range(radius, data.heightmapWidth - radius);
int randY = Random.Range(radius, data.heightmapHeight - radius);
heightMap = stampHillOnHeighmap(randX, randY, radius, heightMap);
}
terrain.terrainData.SetHeights(0, 0, heightMap);
if (lastShapedTerrain) {
lastShapedTerrain.SetNeighbors(null, terrain, null, null);
terrain.SetNeighbors(null, null, null, lastShapedTerrain);
}
lastShapedTerrain = terrain;
print("Wygenerowane");
yield return null;
}