0

Incoming packets are by nature Async. Most things in Unity require you to be on the main thread.

For example: I have a login screen where it disables parts of the UI when you click the button to login. When I receive a bad response I would like to enable the UI so they can try again.

The only ways I can think to handle this is to store a bool that changes with the incoming packet and check that bool every update. That seems hackish to me. Is there some type of system where I can queue these tasks into a list and just go thru them some specified time during the update?

Evan
  • 51
  • 5
  • You can still use threads in Unity but you have to pass the values not directly to the UI components. Create an object for ThreadJobs that will have somehing like `GetState()` method or `GetResponse()` method and from your UI logic you can call these from `Update()` method like `string response = meThreadJob.GetResponse();`. Then you can use it with your UI logic like `meLabel.Text = response;` – mrogal.ski Dec 06 '16 at 12:02
  • It is hackish to do that. [Here](http://stackoverflow.com/questions/41330771/use-unity-api-from-another-thread-or-call-a-function-in-the-main-thread) is a solution for that. – Programmer Dec 26 '16 at 19:07

0 Answers0