Open Nights87 opened 7 months ago
I had the same issue, it appears all network related methods in TwitchLib.PubSub has been updated to use Async methods (see this commit)
From what I've found, running async code on Unity's main thread freezes it, you have to wrap it in a Task.Run(...)
so you can change your snippet to this:
private void Start()
{
// Create new instance of PubSub Client
_pubSub = new PubSub();
// Subscribe to Events
_pubSub.OnWhisper += OnWhisper;
_pubSub.OnPubSubServiceConnected += OnPubSubServiceConnected;
// Connect - hangs when running this
Task.Run(async() => await _pubSub.ConnectAsync());
}
This way it shouldn't hang. The same goes for all the methods that now have an Async
variant.
I don't know if it's the best way to go, it would be nice to update this lib to have a helper to run in coroutines for example, but this works for now.
Upon running the line _pubSub.Connect(); unity just hangs and I have to kill the editor. Running 2023.2.4f1 with HDRP pipeline.
Is there anything I need to add/do?
Code is same as the sample, but ill post anyway