Unity3D播放器尺寸变化?

时间:2014-10-18 14:26:05

标签: javascript html unity3d

我试图在我的网站上更改Unity3D游戏的播放器元素的大小。问题是,在HTML文档本身,这就是我所拥有的。

<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%编辑为我想要的大小。关于如何做到这一点的任何想法?

1 个答案:

答案 0 :(得分:0)

在创建UnityObject2实例时是否尝试使用config?

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