GithubHelp home page GithubHelp logo

Comments (4)

offchan42 avatar offchan42 commented on May 24, 2024 3

If you want that when a button is pressed, it should do something, then you can define a request queue as a field of the HelloRequester class. And whenever a button is pressed, you add a request message to the queue. In this case, the request message could be random because you just want to request without parameters.
Just replace the for loop with

while (true) {
  if (there is a request in the queue) {
    request = queue.Dequeue();
    // send the request to server
    // wait for the response
    // use the response to do whatever you want the button to do
  }
}

from unity3d-python-communication.

rileyshu53 avatar rileyshu53 commented on May 24, 2024

this is such a lifesaver

from unity3d-python-communication.

rileyshu53 avatar rileyshu53 commented on May 24, 2024

I try to use a queue, but every time I click "played", unity freezes :(

from unity3d-python-communication.

offchan42 avatar offchan42 commented on May 24, 2024

@rileyshu53 It's probably because you are blocking the main thread somehow e.g. by an infinite loop or handling messages in the main thread. Make sure you aren't doing that. There are the main thread (Unity Update() function) and the hello requester thread. The requester thread can be blocked but the Unity's main thread must never be blocked.

from unity3d-python-communication.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.