Search Unity

Transfer byte array from javascript on page to webgl

Discussion in 'Web' started by The_Hagvan, Apr 17, 2021.

  1. The_Hagvan

    The_Hagvan

    Joined:
    Sep 15, 2016
    Posts:
    2
    I've been looking for how to do it for a few days now but only found some old threads which didn't really help.
    I receive a BufferArray from my websocket and all I need is somehow to pass the bytes to the game.
    From what I read it is possible to only pass nothing, number, and string using unityInstance.Send().

    Could somebody help me please, my current very hacky solution is not only ugly but I suspect it also wrangles bytes in some places so my deserialization is inconsistent. For example, I have to double the array size so I can have one half to represent if there is zero because if I try to pass a string as is it terminates at null byte.

    I must be missing something.
     
  2. sumpfkraut

    sumpfkraut

    Joined:
    Jan 18, 2013
    Posts:
    242
  3. The_Hagvan

    The_Hagvan

    Joined:
    Sep 15, 2016
    Posts:
    2
    Hey thank you for the responce. But won't it terminate at null? I used something similar before and null bytes cut the string short.