查看: 1205|回复: 1
打印 上一主题 下一主题

[提问] unity3d导入网页的问题

[复制链接]

2508

主题

2

听众

3万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
32806
精华
12

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2013-2-3 09:01:29 |只看该作者 |倒序浏览
他不能容别的div在他上面吗?
一放上就被放到下面了。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="postFlash.js"></script>
<script type="text/javascript" src="UnityObject.js"></script>
<style type="text/css">
html,body,div{margin:0;padding:0;}
  .main_swf{ position:absolute;top:0;bottom:0;left:0;width:100%;height:100%;border:1px solid green; z-index:0;}
  #sec_swf{ position:absolute;border:1px solid red; background-color:#ff0000; z-index:999;top:0;width:600px; height:400px;}
    #close_{ position:absolute;width:25px; height:25px; border:1px solid white; background-color:#CCC;right:0; z-index:999; cursor:pointer;}
  #swf_box{ position:absolute;top:0;width:600px; height:400px; border:1px solid green;}
</style>

</head>

<body>
<div class="main_swf" id="swf" style="position:absolute; z-index:1">
</div>
</body>
<script type="text/javascript">
//创建div
var arr=["p1.swf","p2.swf"];
function setDiv(){
                sec_swf = document.createElement("div");
                sec_swf.setAttribute("id","sec_swf");
                document.body.appendChild(sec_swf);
               
                swf_box = document.createElement("div");
                swf_box.setAttribute("id","swf_box");
                sec_swf.appendChild(swf_box);
               
            close_ = document.createElement("div");
                close_.setAttribute("id","close_");
                //sec_swf.appendChild(close_);
                sec_swf.insertBefore(close_,swf_box);
        }
w=document.body.clientWidth||document.documentElement.clientWidth;
h=document.body.clientHeight||document.documentElement.clientHeight;
if (typeof unityObject != "undefined") {
                        unityObject.embedUnity("swf", "WebPlayer.unity3d", w, h);
                }

//加载swf到sec_swf
        setDiv();
        var flash=new MenuPost(arr[1],"FlashH",600,400,"opaque","#fff","high","page=2")  
        flash.add("swf_box");
        sec_swf.style.visibility = "hidden";

//点击接收un3d的值
function SendToJS(){
        
    //判断是否存在swf_box
        if(document.getElementById("sce_swf")||document.getElementById("swf_box")||document.getElementById("close_")){
                  var flash=new MenuPost(arr[1],"FlashH",600,400,"transparent","#fff","high","page=2")  
                  flash.add("swf_box");
                  
                var sec_swf = document.getElementById("sec_swf");
                var swf = document.getElementById("swf");
                sec_swf.style.visibility = "visible";
                sec_swf.style.top = (h - sec_swf.offsetHeight)/2+"px";
                sec_swf.style.left = (w - sec_swf.offsetWidth)/2+"px";

        }else{
        setDiv();
                var sec_swf = document.getElementById("sec_swf");
                var swf = document.getElementById("swf");
                sec_swf.style.visibility = "visible";
                sec_swf.style.top = (h - sec_swf.offsetHeight)/2+"px";
                sec_swf.style.left = (w - sec_swf.offsetWidth)/2+"px";

                var flash=new MenuPost(arr[1],"FlashH",600,400,"transparent","#fff","high","page=2")  
                flash.add("swf_box");
                }
        
        //clos()
        clos();
}

function clos(){
        var close_ =  document.getElementById("close_");
        close_.onclick=function(){
                var swf_box = document.getElementById("swf_box");
                var sec_swf = document.getElementById("sec_swf");
                sec_swf.removeChild(swf_box);
                document.body.removeChild(sec_swf);
                }
        }
</script>
</html>


分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

2722

主题

42

听众

3万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
38268
精华
111

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

沙发
发表于 2013-2-28 01:59:33 |只看该作者
希望在新的一年里专心的学习好Unity!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2025-7-29 02:39 , Processed in 0.061303 second(s), 28 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部