ブラウザのサイズが変更されたときにUnityWebPlayerコントロールのサイズを変更しようとしています。これが私が適切だと思うコードです:
<!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>
<script type="text/javascript">
<!--
function GetUnity()
{
if (typeof unityObject != "undefined")
{
return unityObject.getObjectById("unityPlayer");
}
return null;
}
function ResizeUnity()
{
//This function properly assigns innerWidth and Height to winWidth and winHeight
GetWindowSize();
var unity = GetUnity();
if(unity != null)
{
//This does not properly resize anything at all
unity.width = winWidth;
unity.height = winHeight;
}
}
}
if (typeof unityObject != "undefined")
{
GetWindowSize();
//This replaces the unityPlayer div below with an actual WebPlayer object
unityObject.embedUnity("unityPlayer", "WebPlayer.unity3d", winWidth, winHeight, params);
}
-->
</script>
<style type="text/css">
<!--
div#unityPlayer {
cursor: default;
height: 100%;
width: 100%;
}
-->
</style>
</head>
<body margin="0" marginwidth="0" marginheight="0" scroll="no" onResize="ResizeUnity()">
<div class="content">
<div id="unityPlayer">
<div class="missing">
<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
</a>
</div>
</div>
</div>
</body>
</html>
alert()
コード内のさまざまなsからResizeUnity()
、ウィンドウのサイズを変更したときに呼び出されていることを確認できます。winWidth
サイズ変更時に、それを確認し、winHeight
適切な値が割り当てられていることを確認できます。ただし、ブラウザウィンドウに何をしても、UnityWebPlayerオブジェクトはロードされたときと同じサイズのままです。
私は何が間違っているのですか?