[Unity菜鸟] Unity Web Player 相关问题 (待完善)

1. 发布网页版Unity自适应网页大小

发布网页版,Unity3D自适应网页大小。这个问题困扰了我很长时间,今天终于把他解决了,给大家分享一下。

这里用Uinty4.0发布网页版,我去掉了里面的标题和下载连接地址的Div,目的是让代码看起来易懂。

自适应网页大小与发布网页时PlayerSettings设置的width和height大小无关,只要讲网页里面的标注的代码设置好,就可以实现u3d自适应网页大小。

<!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>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>Unity Web Player | ceshiExt</title>

<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/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 config = {

width: '100%', //设置成100%

height: '100%' //设置成100%

};

var u = new UnityObject2(config);

jQuery(function() {

u.initPlugin(jQuery("#unityPlayer")[0], "Decor.unity3d");

});

-->

</script>

<style type="text/css">

<!--

html,body{ height:100%; margin:0px auto;} //注意这段样式是后添加进来的

div#unityPlayer {

width: 100%; //设置成100%

margin: 0 auto;

background: #FFFF00;

height: 100%; //设置成100%

}

-->

</style>

</head>

<body>

<div id="unityPlayer">

</div>

</body>

</html>

 

本文链接: http://bbs.9ria.com/thread-207203-1-1.html

 

 

http://blog.csdn.net/libeifs/article/details/7200630

http://www.tuicool.com/articles/fI7ziy

http://blog.sina.com.cn/s/blog_bd56822d010169ag.html

http://edu.china.unity3d.com/learning_document/getData?file=/Manual/WebPlayerDeployment.html

你可能感兴趣的:(unity)