- 最后登录
- 2014-10-23
- 注册时间
- 2011-7-19
- 阅读权限
- 90
- 积分
- 81303
 
- 纳金币
- -1
- 精华
- 11
|
射线检测 射线碰到碰撞体后会返回一个检测信息 包含碰到的物体的名字之类,就是返回一个引用型的变量,这个变量就可以当做你射到那个物体来用。1、使用Camera.ScreenPointToRay得到一条射线,2、然后使用射线检测函数Physics.Raycast,然后会得到RaycastHit 信息,根据信息可以判断你到底点中了什么。Camera.ViewportPointToRay 也行不过这个是基于视口的,超出了你的程序框框就无效。
var gui : GUITexture;
var find : GUITexture;
//var GameObjectName;
function Awake(){
find=GameObject.Find("guiTexture").GetComponent(GUITexture);
find.enabled=false;
}
function OnMouseDown()
{
//find=GameObject.Find("guiTexture").GetComponent(GUITexture);
find.enabled=***e;
Debug.Log(gameObject.name);
www(gameObject.name);
}
function www(Cubename){
// Store the original pixel inset
// and modify it from there.
var originalPixelRect = gui.pixelInset;
// Update the progress bar by scaling the gui texture
// until we reach the end
var stream=new WWW(""+Cubename+".unity3d");
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)
转自unity3D中文学习社区 |
|