- Home /
Browser to unity communication
Hi, I'm trying to communicate the web browser with unity without succesful.
I have read all the questions I could find about in this forum and in google, but I couldn't find a solution. Probably because I am new in unity and english is not my native language.
Following the instructions at: http://unity3d.com/support/documentation/Manual/Unity%20Web%20Player%20and%20browser%20communication.html I have in my html:
<head> <title>Unity Web Player - comm</title> <script type="text/javascript" language="javascript"> <!-- function SaySomethingToUnity() { document.getElementById("UnityContent").SendMessage("MyObject", "MyFunction", "Hello from a web page!"); } --> </script>
<script language='VBScript'>...
In unity I have a GUI Text called GUIText and a GameObject called MyObject with this script attached to it:
function MyFunction(param : String) { GameObject.Find("GUIText").guiText.text = param; }
If some body can help me with this I will be very grateful.
Thanks in advance.
Answer by jonas-echterhoff · Aug 06, 2010 at 03:10 PM
I can't see anything wrong with that setup. But, did you make sure that your javascript SaySomethingToUnity() function is actually called? Like, make a button on the web page to call the function?
Answer by Kuzuk · Aug 06, 2010 at 07:18 PM
Thanks for your help. I know it was a very basic question but I am a javascript beginer.
To make it work, I had to change the function to:
GetUnity().SendMessage("MyObject", "MyFunction", "Hello from a web page!");
With the button or another kind of call to the function its working very well, thanks.