Skip to content
Advertisement

Issue returning data from Python to Unity

This question is an evolution of this: Issue returning header byte from Python to Unity

Now the issue about header byte is solved, but I have a problem during the loop.

The data incoming good but after “n” times the loop break because receive a json string with an entire structure of data with open/close bracket PLUS the next structure of data with open bracket, some data and in the “image:” some data and many of the “” and unless the close bracket.. And the json parser obviously breaks. Why and what can I do? Thanks Below the code revised:

JavaScript

Advertisement

Answer

I don’t have your Unity environment here, so I can’t have tested this.

Something like a loop (likely run in a coroutine or something that doesn’t block Unity’s default handling) like this should be enough to handle a stream of messages of the shape we established before (a 4-byte header signifying the message length, followed by that many bytes of JSON).

JavaScript

ReadPacket should be something like

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement