Open enviel opened 6 years ago
Yes, the callback is running in a background thread, so not operate the UI in that.
Instead, put the data in a variable, the use the main thread to read the variable then operate the UI.
See the example: https://github.com/floatinghotpot/socket.io-unity/blob/master/Demo/SocketIOScript.cs#L68
@floatinghotpot can you please update the lib to support the script that i'm doing? just like how this lib work https://github.com/fpanettieri/unity-socket.io-DEPRECATED crating a variable for every event seems unnecessary if i have lots of events it's going to be messy
I think that is same, the callback is a background thread, you can write log, but you cannot access UI.
@floatinghotpot i'm not accessing UI, i'm accessing player gameobject transform and i can do that in this lib https://github.com/fpanettieri/unity-socket.io-DEPRECATED i can even access UI when using that lib
But your suggestion is good. If initialize a function in main thread to regularly check the queue then call your callback, it should be okay.
yeah and that should be a core element on the lib can you add that to the lib?
I think that is not difficult, just add a wrapper. I will try.
@floatinghotpot thankyou so much sir :)
what's the best practice to set something like transform inside On event
i'm not really experienced with multithreading, from the example all i can found is "lock" which i'm not sure what to put inside
i'm using fpanettieri's before using this, and i can do above script