2014-10-18 49 views
1

我正在嘗試在我的網站上更改Unity3D遊戲的播放器元素大小。問題是,在HTML文檔本身,這是我從中得到的。Unity3D播放器大小變化?

<html> 
<head> 
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> 
    <script type="text/javascript"> 
     <!-- 
     var unityObjectUrl = "http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject2.js"; 
     if (document.location.protocol == 'https:') 
      unityObjectUrl = unityObjectUrl.replace("http://", "https://ssl-"); 
     document.write('<script type="text\/javascript" src="' + unityObjectUrl + '"><\/script>'); 
     --> 
    </script> 
    <script type="text/javascript"> 
    var u = new UnityObject2(); 
     u.observeProgress(function (progress) { 
      var $missingScreen = jQuery(progress.targetEl).find(".missing"); 
      switch(progress.pluginStatus) { 
       case "unsupported": 
        showUnsupported(); 
       break; 
       case "broken": 
        alert("You will need to restart your browser after installation."); 
       break; 
       case "missing": 
        $missingScreen.find("a").click(function (e) { 
         e.stopPropagation(); 
         e.preventDefault(); 
         u.installPlugin(); 
         return false; 
        }); 
        $missingScreen.show(); 
       break; 
       case "installed": 
        $missingScreen.remove(); 
       break; 
       case "first": 
       break; 
      } 
     }); 
     jQuery(function(){ 
      u.initPlugin(jQuery("#unityPlayer")[0], "Tug the Table.unity3d"); 
     }); 
    </script> 
    <title>Tug the Table - TGH</title> 
    <link rel="shortcut icon" href="favicon.ico"> 
    <link rel="stylesheet" type="text/css" href="style.css"> 
    <!-- This Template is a WiP - Please report any bugs to the administrative team at The Gaming Hideout. Thank you. All rights reserved. --> 
</head> 
<body> 
<div id="wrap"> 
    <div id="header"> 
     <h1><img src="VexIMG/header.png" alt="The Gaming Hideout" width="760" height="60"></h1> 
    </div> 
    <div id="navigation"> 
    <div class="navlinks"> 
    <div id="output2"> 
    </div> 
    </div> 
    <script src="nav.js"></script> 
    </div> 
    <div id="body"> 
     <div class="game"> 
     <h2>Tug the Table</h2> 
     <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> 
    <caption>Tug the Table. Theres really nothing else to it.</caption> 
    </div> 
    <div id="footer"> 
    <div id="copyright"> 
     Copyright ? The Gaming Hideout<br> 
     We own no rights on any game on this site unless otherwise noted.<br> 
     All Rights Reserved. 
    </div> 
    <div id="footnav"> 
      <script src="footnav.js"></script> 
     </div> 
    </div> 
</div> 

它的大小不正確的頁面上,所以我嘗試瀏覽代碼的方式來改變它的寬度和高度,我什麼也沒得到。因此,我嘗試從瀏覽器編輯元素代碼,然後從元素瀏覽器中的代碼中看到此代碼,該代碼未顯示在HTML中。

<div id="unityPlayer"> 
    <embed src="Tug the Table.unity3d" type="application/vnd.unity" width="100%" height="100%" firstframecallback="UnityObject2.instances[0].firstFrameCallback();" style="display: block; width: 100%; height: 100%;"> 
</div> 

我需要能夠編輯我的HTML頁面,因此它可以編輯width: 100%height: 100%我自己需要的尺寸。任何想法如何做到這一點?

回答

0

您是否嘗試在創建UnityObject2實例時使用配置?

var config = { 
      width: 500, 
      height: 300, 
      params: { enableDebugging:"0" } 
      ,baseDownloadUrl: "http://webplayer.unity3d.com/download_webplayer-3.x/" 
    }; 
var u = new UnityObject2(config); 
+0

不,現在讓我試試。 – 2014-10-18 16:11:19

+0

很好,謝謝! – 2014-10-18 16:18:20

+0

是的,我發現評論後意識到了一點,所以我刪除了它。 – 2014-10-18 16:18:37