javascript - Resizing Unity WebPlayer element when resizing browser -


i'm trying unity webplayer control resize when browser resized. here's code think pertinent:

<!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 assigns innerwidth , height winwidth , winheight             getwindowsize();              var unity = getunity();             if(unity != null)             {                 //this not resize @                 unity.width = winwidth;                 unity.height = winheight;             }         }     }      if (typeof unityobject != "undefined")      {         getwindowsize();         //this replaces unityplayer div below 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> 

from various alert()s in code, can verify resizeunity() being called when change size of window. can verify winwidth , winheight getting proper values assigned them upon resizing. but, no matter browser window, unity webplayer object stays same size when loaded.

what doing wrong?

it seems getunity() function wasn't grabbing element high enough div hierarchy me resize correct element. updating resizeunity() function did trick:

function resizeunity() {     //this function assigns innerwidth , height winwidth , winheight     getwindowsize();      var unity = document.getelementbyid('unityplayer');     if(unity != null)         {                                unity.style.width = winwidth + "px";             unity.style.height = winheight + "px";         } } 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -