示例#1
0
    /// <summary>
    /// 将所有地形的相同基础数据保存为头文件
    /// </summary>
    /// <param name="path">路径</param>
    private void SaveTDHead(string path)
    {
        Terrain terrain = Terrain.activeTerrain;
        TDHead  tDHead  = new TDHead
        {
            terrainSize         = terrain.terrainData.size,
            ResolutionSize      = terrain.terrainData.detailResolution,
            heightmapPixelError = terrain.heightmapPixelError,
            basemapDistance     = terrain.basemapDistance,
            drawHeightmap       = terrain.drawHeightmap,
        };
        ProtocolBytes protocol = new ProtocolBytes();

        protocol.AddVector3(tDHead.terrainSize);
        protocol.AddInt32(tDHead.ResolutionSize);
        protocol.AddFloat(tDHead.heightmapPixelError);
        protocol.AddFloat(tDHead.basemapDistance);
        protocol.AddBoolen(tDHead.drawHeightmap);
        File.WriteAllBytes(path + "/TerrainData.tdHead", protocol.Encode());
    }