0

I'm having a problem when I try to send the data from my unity code to the javascript code in my page, I need to get a list of strings but it returns undefined.

Code in unity script:

var activeFacility : Facility;

...

function getSpacesNames(){
return activeFacility.getSpacesNames();
}

Javascript code in the html page:

function getList() {
var list = u.getUnity().SendMessage("ObjectManager", "getSpacesNames", null);
console.log(list);
}

How can I get this data from Unity to the javascript code in the page?

Vertexwahn
  • 7,709
  • 6
  • 64
  • 90
  • From reading the manual http://docs.unity3d.com/Manual/UnityWebPlayerandbrowsercommunication.html, it's not clear whether the `SendMessage` function can return a value. Have you checked that `u.getUnity` is not null at the time you are calling SendMessage? I presume not if you're logging out undefined. It might be that you need to go the other way and call a web page function from the Unity web player using `Application.ExternalCall("setSpacesNames", activeFacility.getSpacesNames())` http://docs.unity3d.com/ScriptReference/Application.ExternalCall.html – James Bateson Mar 04 '16 at 17:37
  • I noticed that you tagged unity web player. Just letting you know that web player will be removed from unity on March 16. Anything you do with Web player is useless. Web-gl is the new option. – Programmer Mar 04 '16 at 21:15

0 Answers0