Quantcast
Channel: Questions in topic: "issue"
Viewing all articles
Browse latest Browse all 827

Application.ExternalCall Issue

$
0
0
Hey folks, I've just got started a project which is using a combination of the Unity WebPlayer and a js framework for the UI, but I'm facing a problem trying to make the WebPlayer call a js function in my web page. I know that the way to achieve it is to call the **Application.ExternalCall** function from Unity, but for some unknown reason it doesn't seems to work for me, while I have no problems calling a Unity function from the webpage calling the **getUnity().SendMessage** method. Basically, what I'm trying to do is to get reference to all the lights in the scene, create a List of serializable classes with just some basic informations, serialize a JSON string from the list and finally pass the resulting json to the javascript function in my page. Here's the script attached to an empty game object in the scene: public class Environment : MonoBehaviour { void Start () { Light[] Lights = FindObjectsOfType(typeof(Light)) as Light[]; List LightRecords = new List(); foreach (Light light in Lights) { LightModel record = new LightModel(); record.name = light.name; record.intensity = light.light.intensity; LightRecords.Add(record); } string json = JsonConvert.SerializeObject(LightRecords); Application.ExternalCall("loadStore", json); Debug.Log(json); } } and this is the javascript function in my webpage: For some reason, the alert is never shown.. You can notice a Debug.log at the end of the Unity Script. Trying to run the scene from unity the json is logged correctly so everything works there [{"name":"myLight","intensity":1.0},{"name":"dayLight","intensity":0.5}] Can you guys shed some light here on what I'm doing wrong? Any help will be highly appreciated! Thanks

Viewing all articles
Browse latest Browse all 827

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>