UnityEngine.TerrainData.SetHeightsDelayLOD C# (CSharp) Method

SetHeightsDelayLOD() public method

public SetHeightsDelayLOD ( int xBase, int yBase, float heights ) : void
xBase int
yBase int
heights float
return void
        public void SetHeightsDelayLOD(int xBase, int yBase, float[,] heights)
        {
            if (heights == null)
            {
                throw new ArgumentNullException("heights");
            }
            int length = heights.GetLength(0);
            int width = heights.GetLength(1);
            if (((xBase < 0) || ((xBase + width) < 0)) || ((xBase + width) > this.heightmapWidth))
            {
                object[] args = new object[] { xBase, xBase + width, this.heightmapWidth };
                throw new ArgumentException(UnityString.Format("X out of bounds - trying to set {0}-{1} but the terrain ranges from 0-{2}", args));
            }
            if (((yBase < 0) || ((yBase + length) < 0)) || ((yBase + length) > this.heightmapHeight))
            {
                object[] objArray2 = new object[] { yBase, yBase + length, this.heightmapHeight };
                throw new ArgumentException(UnityString.Format("Y out of bounds - trying to set {0}-{1} but the terrain ranges from 0-{2}", objArray2));
            }
            this.Internal_SetHeightsDelayLOD(xBase, yBase, width, length, heights);
        }

Usage Example

コード例 #1
0
    public void FillTerrain(float[][] input, TerrainData tData, Terrain myTerrain, int xBase, int yBase)
    {
        /* Fills terrain with values from scanline and quantization, but it must be divided by large number.
         * Terrain needs float values between 0 and 1.
         */
        res = tData.heightmapResolution;
        heights = new float[res, res];

        for (int i = 0; i < res; i++) {
            for (int j = 0; j < res; j++) {
                heights[i, j] = input[i][j] / 70;
            }
        }
        tData.SetHeightsDelayLOD(xBase, yBase, heights);
    }