zoukankan      html  css  js  c++  java
  • 动态加载网上或者本地场景的后续

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

    修改后:

    View Code
    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)

    再次感谢群里的carlos.yang对我的指点。

  • 相关阅读:
    mock数据
    关于适配各种浏览器的图片预览。
    闭包
    兼容性 适配
    递归 使用callee
    webservice的model层命名空间不同的问题
    删除右键菜单中的Git
    windows server core 设置shell 及切换
    设置共享用户名密码
    Windows Remote Shell(WinRM)使用介绍
  • 原文地址:https://www.cnblogs.com/Mygirl/p/2003125.html
Copyright © 2011-2022 走看看