找回密码
 立即注册
楼主: 强子

[脚本] 动态加载场景资源代码JS

[复制链接]
发表于 2013-3-5 08:57 | 显示全部楼层 |阅读模式

var gui : GUITexture;
var find : GameObject;
var GameObjectName;
function Awake(){
//找到guiTexture,当初始加载时让其不可用
   find=GameObject.Find("guiTexture");
   find.active=false;
   GameObjectName=GameObject.Find("Cube").tag;//通过tag来传递参数给www()函数
}

function OnMouseDown(){
   find.active=true;
   //Debug.Log(GameObjectName);
   var SenceName=GameObjectName;
   www(SenceName);
}

function www(Cubename){
// Store the original pixel inset
// and modify it from there.
var originalPixelRect = gui.pixelInset;

功能及使用说明:<br>1、建立一个Cube,然后将这段代码加到Cube上。<br>2、建立一个GUITexture,并命名为guiTexture,选择Texture。这个GUITexture主要是用作进度条的。<br>功能:动态加载网上或者本地场景<br>点击Cube,加载场景,等进度条不再变化时进入你想进入的场景,点击时Cube没有变化,希望大家可以完善它。<br><br>

// Update the progress bar by scaling the gui texture
// until we reach the end
// var stream=new WWW("http://unity3d.com/gallery/hosted-demos/dressingroom.unity3d");本地连接官网上的例子
var stream=new WWW(""+Cubename+".unity3d");//CubeName为你将要下载的场景名字
while (!stream.isDone)
{
gui.pixelInset.xMax = originalPixelRect.xMin+ stream.progress * originalPixelRect.width;
yield;
}
// Update it one last time before loading
gui.pixelInset.xMax = originalPixelRect.xMax;
stream.LoadUnityWeb();
}
@script RequireComponent (GUITexture)

评分

参与人数 1鲜花 +1 收起 理由
c68686 + 1

查看全部评分

发表于 2013-4-6 21:17 | 显示全部楼层
{:5_424:}{:5_424:}{:5_424:}{:5_424:}
发表于 2017-3-6 15:14 | 显示全部楼层
好帖就是要顶
发表于 2017-3-6 15:56 | 显示全部楼层
顶顶多好
发表于 2017-3-6 15:51 | 显示全部楼层
真心顶
发表于 2017-3-6 15:07 | 显示全部楼层
很好哦
发表于 2017-3-6 15:15 | 显示全部楼层
不错不错
发表于 2017-4-27 17:42 | 显示全部楼层
很不错
发表于 2017-4-27 17:46 | 显示全部楼层
楼主是超人
发表于 2017-4-27 18:09 | 显示全部楼层
顶顶多好
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-3 18:59 , Processed in 0.127794 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表