hi,
i try to get that working:
http://unity3d.com/support/documentation/Manual/Unity%20Web%20Player%20and%20browser%20communication.html
i build the webplayer with a gameobject named MyObject and a script attached with that code:
function MyFunction()
{
transform.Translate(1, 0, 0);
}
and here is the html file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Unity Web Player | WebPlayer</title>
<script type="text/javascript" src="http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js"></script>
<script type="text/javascript">
<!--
function GetUnity() {
if (typeof unityObject != "undefined") {
return unityObject.getObjectById("unityPlayer");
}
return null;
}
if (typeof unityObject != "undefined") {
unityObject.embedUnity("unityPlayer", "WebPlayer.unity3d", 600, 450);
}
-->
</script>
<script type="text/javascript" language="javascript">
<!--
function SaySomethingToUnity()
{
var unity = unityObject.getObjectById("UnityContent");
unity.SendMessage("MyObject", "MyFunction");
}
-->
</script>
<style type="text/css">
<!--
body {
font-family: Helvetica, Verdana, Arial, sans-serif;
background-color: white;
color: black;
text-align: center;
}
a:link, a:visited {
color: #000;
}
a:active, a:hover {
color: #666;
}
p.header {
font-size: small;
}
p.header span {
font-weight: bold;
}
p.footer {
font-size: x-small;
}
div.content {
margin: auto;
width: 600px;
}
div.missing {
margin: auto;
position: relative;
top: 50%;
width: 193px;
}
div.missing a {
height: 63px;
position: relative;
top: -31px;
}
div.missing img {
border-width: 0px;
}
div#unityPlayer {
cursor: default;
height: 450px;
width: 600px;
}
-->
</style>
</head>
<body>
<p class="header"><span>Unity Web Player | </span>WebPlayer</p>
<div class="content">
<div id="unityPlayer">
<div class="missing">
<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
<img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
</a>
</div>
</div>
</div>
<p class="footer">« created with <a href="http://unity3d.com/unity/" title="Go to unity3d.com">Unity</a> »</p>
<a href="javascript:SaySomethingToUnity()">
KLICK</a>
</body>
</html>
but nothing happens when i klick the “KLICK” button.
and how do i find out whats the ID of the unitywebplayer? probaply thats the problem.
var unity = unityObject.getObjectById(“UnityContent”);
i also tried:
var unity = unityObject.getObjectById(“unityPlayer”);
and more.
thx!