Noobie help with probably Multi Threading.

Hello,

I have an Unity App that has just a label in the center of the screen, the Main Camera GameObject, a SOAPComm object and a Display Game Object like so :

MainCamera

  • mainScript (acts as a init object and activates the other object. Also is the link between all objects for reference.)
    SoapComm
  • soapScript (communicates to the server)
    Display
  • displayScript (updates the label)

Workflow :

  1. mainScript starts. Enables the Displayer which shows the Label with the default value of “Connecting…”.
  2. mainScript enables the SoapComm => soapScript.
  3. mainScript after SoapComm Init, tells SoapComm to login.
  4. After Login succesfull SoapComm start downloading data for 20 object.
    (While the Soap function is being called 20 times - 1 for each of the objects to download data for, I want the label to state “Downloading Object 1” then 2,3,4 and so on )

What happens is that the App starts, freezes for a bit, then the label displays “Downloading Object 20” and at that point all SOAP operations are done.

How can I have the label change while the process is running ? What am I doing wrong ?

I am not 100 percent sure but I think you can use the Thread class and give a callback (or delegate i think is the C# term) that you update the main thread loop after each object is downloaded. You might have to extend the Thread class for this functionality.

I would suggest looking into the threading tutorial on the .NET website that shows the basics of threading application code.