当前位置: 首页>>代码示例>>C#>>正文


C# Terrain.SetNeighbors方法代码示例

本文整理汇总了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);
    }
开发者ID:TheCraiggers,项目名称:MoonKrieg,代码行数:31,代码来源:DupeTerrain.cs

示例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;
    }
开发者ID:zipOrg,项目名称:CemeteryShoeter,代码行数:35,代码来源:Generator.cs


注:本文中的UnityEngine.Terrain.SetNeighbors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。