Search Unity

Getting function returns when calling C# from JS

Discussion in 'Scripting' started by klindeman, Sep 18, 2005.

  1. klindeman

    klindeman

    Joined:
    Jun 13, 2005
    Posts:
    295
    I have a function I wrote in C# that takes in a value, and messes with it some, and proceeds to return it at the end. I needed to call that function from JS, but I do not see how to use SendMessage to get that return value as well. I can run the function fine it seems, but I need access to the return value. Aside from rewriting my JS in C#, or making some blank game objects that it changes the values on instead of returning, and polling for those values, any other ideas?
     
  2. Richard_B

    Richard_B

    Joined:
    Jul 22, 2005
    Posts:
    436
    There were some posts a while ago to do with C# and JS talking to each other.. couldn't find quiclkly, but if you search though th past Scripting threads you should find it.

    Richard.
     
  3. klindeman

    klindeman

    Joined:
    Jun 13, 2005
    Posts:
    295
    Yeah, but from what I could tell none of them involve what I am asking.
     
  4. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    At the moment this is a bit hacky, until we add more interoperability between js and c#.

    2 ways
    1) Dont use a return value, but send the return value back with SendMessage.
    2) Use PlayerPrefs to write the return value into the prefs then read it back.