Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Is SendMessage Broken for C# functions with parameters?

Discussion in 'Scripting' started by Jehsup, Sep 2, 2008.

  1. Jehsup

    Jehsup

    Joined:
    May 22, 2008
    Posts:
    166
    In a configuration managing script I have the following call on Start()...

    Code (csharp):
    1.  
    2. Application.ExternalCall("getClientSettingsURL");
    3.         Application.ExternalCall("getClientItineraryURL");
    4.  
    This calls the functions below in the html page "hosting" my Unity Web Player ...

    Code (csharp):
    1.  
    2. function getClientSettingsURL(){
    3.             // call this to get the client configuration XML URL
    4.             var configPath = "http://unityserver/sld/RCCL_Settings.xml";       
    5.             GetUnity.SendMessage("InitializationManager", "setConfigXMLURL", configPath);
    6.                            
    7.             }
    8.            
    9.             function getClientItineraryURL(){
    10.             // call this to get the client itinerary XML URL
    11.             var itineraryPath = "http://unityserver/sld/RCCL_Itinerary.xml";
    12.             GetUnity.SendMessage("InitializationManager", "setItineraryXMLURL", itineraryPath);
    13.                        
    14.             }
    15.  
    16.  
    17.  
    These in turn call back to the same configuration manager

    Code (csharp):
    1.  
    2. void setConfigXMLURL(string clientSettings)
    3.     {
    4.         settingsXmlURL = clientSettings;
    5.         print("settings: " + settingsXmlURL);
    6.     }
    7.    
    8.     void setItineraryXMLURL(string itinerary)
    9.     {
    10.         itineraryXmlURL = itinerary;
    11.         print("itinerary: " + itineraryXmlURL);
    12.     }
    13.  
    14.  

    My print statements never exectute on the funcitons called from my web page. If I put alert statements into the web page functions I can see my URLs are correct. If I put the alert functions AFTER the SendMessage functions in the web page stuff. The alerts never gets called. The SendMessage function is the hangup.

    In addition to the functions listed in my web page I have the following 2 functions for toggling fullscreen and a render mode. These parameterless functions work just fine.

    Code (csharp):
    1.  
    2. function switchToFullScreenMode() {
    3.             // code here to cause the plugin to switch to full screen mode
    4.                 GetUnity().SendMessage("GUIobject", "switchToFullScreen", 0);
    5.             }
    6.  
    7.             function switchToDrawerMode() {
    8.             // code here to cause the plugin to switch to in drawer mode
    9.                 GetUnity().SendMessage("GUIobject", "switchToDrawer", 0);
    10.             }
    11.  
    12.  
    Any ideas what is going on?

    --J
     
  2. Jehsup

    Jehsup

    Joined:
    May 22, 2008
    Posts:
    166
    Nobody? I mucked up and put this here instead of the support forum, can admin or something move it there? This really has me in a bind and behind the 8 ball with no real way to debug anything.
     
  3. Jehsup

    Jehsup

    Joined:
    May 22, 2008
    Posts:
    166
    Filed an official bug with simple example that fails. I'll post resolution if there is any for anyone else that is interested.

    FYI. In making the simple example I noticed that SendMessage from webpage function with a parameter (string is only thing I tested because that is what I need) fails going to both JS and C# functions in the Unity Web Player.

    (Case # 35119)
     
  4. Pierrick

    Pierrick

    Joined:
    Feb 20, 2008
    Posts:
    4
    I'm not sure but I think in Javascript you should use GetUnity().SendMessage() and not GetUnity.SendMessage() because GetUnity() is a function.