private void OnCameraImageReceived(MeshDataUpdates meshes, Texture2D camTexture) { meshes.WriteCameraImageColors(_camera, camTexture); var data = MeshSerializer.GenerateMeshData(meshes); DataReadyEvent?.Invoke(data); }
public void SendUpdate(List <MeshFilter> added, List <MeshFilter> updated, List <MeshFilter> removed) { var serializableUpdate = MeshDataUpdates.Generate(added, updated, removed); _cameraImageReceiver.TryGetLatestCameraImage(texture2D => OnCameraImageReceived(serializableUpdate, texture2D)); }
public static byte[] GenerateMeshData(MeshDataUpdates meshes) { var streamSize = sizeof(byte); // streamType streamSize += CalculateSizeForMeshes(meshes.Added); streamSize += CalculateSizeForMeshes(meshes.Updated); streamSize += CalculateSizeForMeshes(meshes.Removed); var data = new byte[streamSize]; var dstOffSet = 0; SerializationHelper.WriteStreamType(SerializationHelper.StreamType.Mesh, ref data, ref dstOffSet); WriteMeshArray(meshes.Added, ref data, ref dstOffSet); WriteMeshArray(meshes.Updated, ref data, ref dstOffSet); WriteMeshArray(meshes.Removed, ref data, ref dstOffSet); return(data); }