public void SerializeTerrain(List <byte> bytes, Terrain terrain) { if (terrain == null) { return; } if (terrain.terrainData == null) { return; } R_SerializationHelper.SerializeString(bytes, terrain.name); R_SerializationHelper.SerializeVector3(bytes, terrain.transform.position); R_SerializationHelper.SerializeFloat(bytes, terrain.basemapDistance); #if UNITY_5 || UNITY_2017 || UNITY_2018_1 || UNITY_2018_2 || UNITY_2018_3 || UNITY_2018_4 R_SerializationHelper.SerializeBool(bytes, terrain.castShadows); #else R_SerializationHelper.SerializeInt(bytes, (int)terrain.shadowCastingMode); #endif R_SerializationHelper.SerializeBool(bytes, terrain.collectDetailPatches); R_SerializationHelper.SerializeFloat(bytes, terrain.detailObjectDensity); R_SerializationHelper.SerializeFloat(bytes, terrain.detailObjectDistance); R_SerializationHelper.SerializeBool(bytes, terrain.drawHeightmap); R_SerializationHelper.SerializeBool(bytes, terrain.drawTreesAndFoliage); R_SerializationHelper.SerializeInt(bytes, terrain.heightmapMaximumLOD); R_SerializationHelper.SerializeFloat(bytes, terrain.heightmapPixelError); #if UNITY_5 || UNITY_2017 || UNITY_2018_1 || UNITY_2018_2 || UNITY_2018_3 || UNITY_2019_1 R_SerializationHelper.SerializeFloat(bytes, terrain.legacyShininess); R_SerializationHelper.SerializeColor(bytes, terrain.legacySpecular); #endif R_SerializationHelper.SerializeInt(bytes, terrain.lightmapIndex); R_SerializationHelper.SerializeVector4(bytes, terrain.lightmapScaleOffset); if (terrain.materialTemplate != null) { bytes.Add(1); R_SerializationHelper.SerializeString(bytes, terrain.materialTemplate.name); } else { bytes.Add(0); } #if UNITY_5 || UNITY_2017 || UNITY_2018_1 || UNITY_2018_2 || UNITY_2018_3 || UNITY_2019_1 R_SerializationHelper.SerializeInt(bytes, (int)terrain.materialType); #endif R_SerializationHelper.SerializeInt(bytes, terrain.realtimeLightmapIndex); R_SerializationHelper.SerializeVector4(bytes, terrain.realtimeLightmapScaleOffset); R_SerializationHelper.SerializeInt(bytes, (int)terrain.reflectionProbeUsage); R_SerializationHelper.SerializeFloat(bytes, terrain.treeBillboardDistance); R_SerializationHelper.SerializeFloat(bytes, terrain.treeCrossFadeLength); R_SerializationHelper.SerializeFloat(bytes, terrain.treeDistance); R_SerializationHelper.SerializeInt(bytes, terrain.treeMaximumFullLODCount); SerializeTerrainData(bytes, terrain.terrainData); // Debug.Log(bytes.Count); }