- Home /
Why is GetUnity not working in my HTML?
I did the following modifications to the auto-generated html a web build creates:
<script type="text/javascript" src="http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js"></script>
<div id="fb-root"></div>
<script type="text/javascript">
<!--
function GetCurrentUser() //When we are logged in this shows our name.
{
alert("You called?");
getUnity().SendMessage("Object", //Game object name, make sure this exists!
"GetCurrentUserComplete", //Method to call
"SomeData"); //Our serialized facebook data
}
function GetUnity() {
if (typeof unityObject != "undefined") {
return unityObject.getObjectById("unityPlayer");
alert("Unity object is there");
}
return null;
}
if (typeof unityObject != "undefined") {
unityObject.embedUnity("unityPlayer", "WebPlayer.unity3d", 800, 600);
}
-->
</script>
The relevant code in my Object in Unity looks like this:
void Start () {
Application.ExternalCall("GetCurrentUser");
}
public void GetCurrentUserComplete(string data){
Logger.Log("Dude's data: "+data);
}
Of the alerts I've placed, only the one in GetCurrentUser is showing, so I'm thinking Unity can communicate with the browser, but not vice versa, I'm not receiving anything in Unity. Also, since the alert in GetUnity is not showing, I'm thinking my Unity Object is not being created. How could I go about fixing this?
Answer by J3-Gaming · Sep 18, 2012 at 05:32 AM
You forgot an uppercase letter
GetUnity().SendMessage("Object", "GetCurrentUserComplete", "SomeData");
Your answer
![](https://koobas.hobune.stream/wayback/20220613080424im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity3d + Android Webkit/Webview 1 Answer
how to debug externalcall in editor with browser javascript? 1 Answer
Open a local html file in the Android's default browser 1 Answer
Web Player Crashes Window Instance 1 Answer
java to c# 2 Answers