public override void OnImportAsset(AssetImportContext ctx) { using (var reader = new PointCloudReader(Path.Combine(Directory.GetCurrentDirectory(), ctx.assetPath))) { if (reader.PointXYZRGBAs.IsCreated) { SaveMesh(ctx, reader.PointXYZRGBAs.CoordinateRosToUnity().ToUnityColor().ToMesh()); } else if (reader.PointXYZIs.IsCreated) { var colored = reader.PointXYZIs.IntensityToColor(); SaveMesh(ctx, colored.CoordinateRosToUnity().ToMesh()); colored.Dispose(); } } AssetDatabase.Refresh(); }
public void Receive() { try { while (connected && receiving) { System.Diagnostics.Debug.WriteLine("Client Socket accepting"); byte[] sizebuffer = new byte[8]; acceptor.Receive(sizebuffer, 0, sizebuffer.Length, 0); //receive length of data int size = 0; size = BitConverter.ToInt32(sizebuffer, 0); MemoryStream ms = new MemoryStream();//will hold the data that is received while (size > 0) { var buffer = size < acceptor.ReceiveBufferSize ? new byte[size] : new byte[acceptor.ReceiveBufferSize]; int receive = acceptor.Receive(buffer, 0, buffer.Length, 0); //subtract the size of the received data from the size size -= receive; //write the received data to the memory stream ms.Write(buffer, 0, buffer.Length); } if (size == 0) { ms.Close(); data = ms.ToArray(); PointCloudReader.ReadFromBinary(data); //string datastring = Encoding.UTF8.GetString(data); //Core.PointClouds.PointCloudReader.ReadFromString(datastring); ms.Dispose(); } } } catch (Exception exp) //catch socket exceptions { System.Diagnostics.Debug.WriteLine("Exceptions catched:\n" + exp); } }