Closed SachinTichkule closed 2 years ago
Possible reason: The code that receives the message works in another thread, and the update UI elements needs to be in the UI thread. (This is the experience I got on WinForms or WPF, I don't know Unity)
Perhaps, this library can help you. https://github.com/itisnajim/SocketIOUnity .it is Wrapper for socket.io-client-csharp to work with Unity
Example code: void start() { MySocket.socket.On(SocketEvents.usercoins, response => { JSONNode json = JSONNode.Parse(response.GetValue());
Coins = json["coins"];
BetAmount = json["betting"];
SetBetText(json["betting"]);
SetCoinText(json["coins"]);
});
}
I want to update my text. I try force to update canvas.forceUpdate() but didnot update
I want to use on functionality.
Example:
await MySocket.MyEmitAsync(eventName: SocketEvents.usercoins, data: jsonData, response => { Coins = response["coins"]; BetAmount = response["betting"]; SetBetText(response["betting"]); SetCoinText(response["coins"]); });