Search Unity

Unable to move when doing External Call (SAPI)

Discussion in 'Scripting' started by cospace, Oct 5, 2010.

  1. cospace

    cospace

    Joined:
    Oct 5, 2010
    Posts:
    7
    Hi, in my browser based project, i am using the following to call a javascript function which calls the SAPI on the client.
    Code (csharp):
    1. Application.ExternalCall("SpeakText", curMsg);
    the javascript code is

    Code (csharp):
    1.  
    2. function SpeakText(msg)
    3. {
    4.      VoiceObj.Speak( msg , 2);
    5. }
    The code works however, while the speech is being played, unity freezes and nothing including the player can move. I cannot click on any buttons or input any text field, everything freezes. This is especially bad when speaking long sentences as the player is unable to do anything for long periods of time.

    Does anyone have any idea what is causing this and how it can be rectified ?
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    you likely have an infinite loop in speak which does not use yield or something like this
     
  3. cospace

    cospace

    Joined:
    Oct 5, 2010
    Posts:
    7
    The speak is actually a javascript function in a jsp file on which the browser game is served. It does not freeze indefinitely, only while the sentence is being read, where would the yield be ? In Unity project or in the jsp file ?