Unity3D动态加载网上或者本地场景的后续

用射线检测法的可行性和优点。射线检测  射线碰到碰撞体后会返回一个检测信息 包含碰到的物体的名字之类,就是返回一个引用型的变量,这个变量就可以当做你射到那个物体来用。1、使用Camera.ScreenPointToRay得到一条射线,2、然后使用射线检测函数Physics.Raycast,然后会得到RaycastHit 信息,根据信息可以判断你到底点中了什么。Camera.ViewportPointToRay 也行不过这个是基于视口的,超出了你的程序框框就无效。不过这个我没试,由于时间仓促,等有空再试吧。

修改后:

1 var gui : GUITexture;
2  var find : GUITexture;
3  //var GameObjectName;
4 function Awake(){
5    find=GameObject.Find("guiTexture").GetComponent(GUITexture);
6    find.enabled=false;
7 }
8
9 function OnMouseDown()
10 {
11    //find=GameObject.Find("guiTexture").GetComponent(GUITexture);
12    find.enabled=true;
13    Debug.Log(gameObject.name);
14    www(gameObject.name);
15 }
16
17 function www(Cubename){
18 // Store the original pixel inset
19 // and modify it from there.
20 var originalPixelRect = gui.pixelInset;
21
22 // Update the progress bar by scaling the gui texture
23 // until we reach the end
24 var stream=new WWW(""+Cubename+".unity3d");
25 while (!stream.isDone)
26 {
27 gui.pixelInset.xMax = originalPixelRect.xMin
28 + stream.progress * originalPixelRect.width;
29 yield;
30 }
31 // Update it one last time before loading
32 gui.pixelInset.xMax = originalPixelRect.xMax;
33 stream.LoadUnityWeb();
34 }
35 @script RequireComponent (GUITexture)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值