本文整理汇总了C#中TerrainData.GetData方法的典型用法代码示例。如果您正苦于以下问题:C# TerrainData.GetData方法的具体用法?C# TerrainData.GetData怎么用?C# TerrainData.GetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TerrainData
的用法示例。
在下文中一共展示了TerrainData.GetData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Construct
public override void Construct(TerrainData data)
{
Vector3 position = transform.position;
for (int y = 0; y < data.Height; y++)
{
for (int x = 0; x < data.Width; x++)
{
if (data.GetData(x, y) > 0)
{
float worldX = x * m_blockSize + position.x;
float worldZ = y * m_blockSize + position.z;
float worldY = position.y;
GameObject newBlock = (GameObject) Instantiate(m_blocks[data.GetData(x, y) - 1], new Vector3(worldX, worldY, worldZ),
Quaternion.identity);
}
}
}
List<EmptyTerrainBlock> emptyTerrain = new List<EmptyTerrainBlock>(FindObjectsOfType<EmptyTerrainBlock>());
int bodyBlock = Random.Range(0, emptyTerrain.Count);
Instantiate(m_bodyItems[Random.Range(0, m_bodyItems.Length)], emptyTerrain[bodyBlock].transform.position + Vector3.up * m_blockSize * 0.5f + Vector3.up * m_itemOffset, Quaternion.identity);
emptyTerrain.RemoveAt(bodyBlock);
int headBlock = Random.Range(0, emptyTerrain.Count);
Instantiate(m_headItems[Random.Range(0, m_headItems.Length)], emptyTerrain[headBlock].transform.position + Vector3.up * m_blockSize * 0.5f + Vector3.up * m_itemOffset, Quaternion.identity);
emptyTerrain.RemoveAt(headBlock);
int leftArm = Random.Range(0, emptyTerrain.Count);
Instantiate(m_armItems[Random.Range(0, m_armItems.Length)], emptyTerrain[leftArm].transform.position + Vector3.up * m_blockSize * 0.5f + Vector3.up * m_itemOffset, Quaternion.identity);
emptyTerrain.RemoveAt(leftArm);
int rightArm = Random.Range(0, emptyTerrain.Count);
Instantiate(m_armItems[Random.Range(0, m_armItems.Length)], emptyTerrain[rightArm].transform.position + Vector3.up * m_blockSize * 0.5f + Vector3.up * m_itemOffset, Quaternion.identity);
emptyTerrain.RemoveAt(rightArm);
int leftLeg = Random.Range(0, emptyTerrain.Count);
Instantiate(m_legItems[Random.Range(0, m_legItems.Length)], emptyTerrain[leftLeg].transform.position + Vector3.up * m_blockSize * 0.5f + Vector3.up * m_itemOffset, Quaternion.identity);
emptyTerrain.RemoveAt(leftLeg);
int rightLeg = Random.Range(0, emptyTerrain.Count);
Instantiate(m_legItems[Random.Range(0, m_legItems.Length)], emptyTerrain[rightLeg].transform.position + Vector3.up * m_blockSize * 0.5f + Vector3.up * m_itemOffset, Quaternion.identity);
emptyTerrain.RemoveAt(rightLeg);
int startBlock = Random.Range(0, emptyTerrain.Count);
Instantiate(m_startArea, emptyTerrain[bodyBlock].transform.position + Vector3.up * m_blockSize * 0.5f,
Quaternion.identity);
emptyTerrain.RemoveAt(startBlock);
}