纳金网

标题: 动态加载网上或者本地场景问题 [打印本页]

作者: 会飞的鱼    时间: 2012-2-2 15:22
标题: 动态加载网上或者本地场景问题
射线检测  射线碰到碰撞体后会返回一个检测信息 包含碰到的物体的名字之类,就是返回一个引用型的变量,这个变量就可以当做你射到那个物体来用。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中文学习社区




欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5