- Home /
How do you get webplayer 3.1 to go full window?
I need the html wrapper for the web player to let the player go 'full window' (not full screen mind you). That is, I want it to fill the div/frame/window of whatever it's sitting in.
I tried putting '100%' in where ever I could see (but not in the .js file). This got me as far as it going full-width, but the height is always about 400 pixels.
What's the best way of accomplishing this?
Answer by Art 1 · Feb 04, 2011 at 11:01 PM
try this
add margin: 0px 0px to the body style and div.content style
add this code to the script GetUnity():
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' )
{
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
}
else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
{
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
}
else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
{
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
unityObject.embedUnity("unityPlayer", "MyAwesomGame.unity3d", myWidth , myHeight);
that may be more than you need but it works for me. When the page loads, it will set the game resolution to the current window size, so if they resize the window, it stays the same. If you want that to stretch to fit dynamically, that's something else.