private void Awake()
    {
        var objtar         = kcell.gameObject;
        var transformcache = this.transform;

        cells = new TerrainCell[ConfigParam.BLOCKWIDTHCOUNT * ConfigParam.BLOCKHEIGHTCOUNT];

        LC_Helper.DoubleLoop(ConfigParam.BLOCKWIDTHCOUNT, ConfigParam.BLOCKHEIGHTCOUNT, (i, j) =>
        {
            var ins  = GameObject.Instantiate(objtar, transformcache);
            var cell = ins.GetComponent <TerrainCell>();
            ins.name = objtar.name + string.Format("({0},{1})", i, j);
            cells[i * ConfigParam.BLOCKHEIGHTCOUNT + j] = cell;

            cell.Gen(i, j);
            cell.Apply();
        });
    }
    public void Gen(int BlockCountx, int BlockCountz)
    {
        vertices  = new List <Vector3>();
        colors    = new List <Color>();
        uvs       = new List <Vector2>();
        triangles = new List <int>();

        var xBase = ConfigParam.PERBLOCKNUMBERSIZE * BlockCountx;
        var zBase = ConfigParam.PERBLOCKNUMBERSIZE * BlockCountz;

        var heightx = ConfigParam.PERBLOCKCOUNT * BlockCountx;
        var heightz = ConfigParam.PERBLOCKCOUNT * BlockCountz;

        this.transform.localPosition = new Vector3(xBase, 0, zBase);

        //vertice;
        //ConfigParam.PERBLOCKCOUNT cell //ConfigParam.PERBLOCKCOUNT + 1 vertices;
        LC_Helper.DoubleLoop(ConfigParam.PERBLOCKCOUNTEX + 1, ConfigParam.PERBLOCKCOUNTEX + 1, (i, j) => {
            float x = i * ConfigParam.PERBLOCKWORLDSIZE; // + xBase;
            float z = j * ConfigParam.PERBLOCKWORLDSIZE; //+ zBase;

            float xx = heightx + ConfigParam.PERBLOCKUVSIZE * i;
            float zz = heightz + ConfigParam.PERBLOCKUVSIZE * j;

            //             int xx = (int)(heightx + ConfigParam.PERBLOCKUVSIZE * i);
            //             int zz = (int)(heightz + ConfigParam.PERBLOCKUVSIZE * j);

            //float y = GetHeight(xx, zz) * ConfigParam.BLOCKHEIGHT;
            float y = GetHeight(xx, zz) * ConfigParam.BLOCKHEIGHT;

            var temp = new Vector3(x, y, z);

            //kHeightMap.GetPixel(indexi, indexi);

            vertices.Add(temp);
            colors.Add(Color.white);
            uvs.Add(GetUV(xx, zz));
        });

        //triangles;

        LC_Helper.DoubleLoop(ConfigParam.PERBLOCKCOUNTEX, ConfigParam.PERBLOCKCOUNTEX, (i, j) => {
            //PerCount = ConfigParam.PERBLOCKCOUNT + 1;
            //LeftTop = i * PerCount + j
            //RightTop = i * PerCount + j + i
            //LeftDown = ( i + 1 ) * PerCount + j;
            //RightDown = ( i + 1 ) * PerCount + j + 1;

            int PerCount  = ConfigParam.PERBLOCKCOUNTEX + 1;
            var LeftTop   = i * PerCount + j;
            var RightTop  = LeftTop + 1;
            var LeftDown  = (i + 1) * PerCount + j;
            var RightDown = LeftDown + 1;

            triangles.Add(LeftTop);
            triangles.Add(RightDown);
            triangles.Add(LeftDown);

            triangles.Add(LeftTop);
            triangles.Add(RightTop);
            triangles.Add(RightDown);
        });
    }