• <output id="aynwq"><form id="aynwq"><code id="aynwq"></code></form></output>

    <mark id="aynwq"><option id="aynwq"></option></mark>
  • <mark id="aynwq"><option id="aynwq"></option></mark><label id="aynwq"><dl id="aynwq"></dl></label>
  • 學習啦>學習電腦>電腦硬件知識>鍵盤鼠標>

    Unity3d鼠標拖拽物體

    時間: 沈迪豪908 分享

      愛學習的小伙伴們,可能都有了解過Unity3d ,但是你知道Unity3d 怎么使用鼠標拖拽物體嗎?

      Unity3d使用鼠標拖拽物體的具體代碼

      //Drag object using mouse

      //editor by faye euler

      //add script components to the collider Object with need to be draging

      //將代碼附加到要被拖拽的collider物體上

      function Update () {

      }

      var screenSpace;

      var offset;

      function OnMouseDown(){

      //translate the cubes position from the world to Screen Point

      //轉換對象位置,從世界點到屏幕座標

      screenSpace = Camera.main.WorldToScreenPoint(transform.position);

      //calculate any difference between the cubes world position and the mouses Screen position converted to a worldpoint

      //在對象世界座標與鼠標屏幕座標計算任何不同,轉換到世界點上

      offset = transform.position - Camera.main.ScreenToWorldPoint(Vector3(Input.mousePosition.x,Input.mousePosition.y, screenSpace.z));

      }

      /*

      OnMouseDrag is called when the user has clicked on a GUIElement or Collider and is still holding down the mouse.

      OnMouseDrag is called every frame while the mouse is down.

      */

      function OnMouseDrag () {

      //keep track of the mouse position

      //保持鼠標位置追蹤

      var curScreenSpace = Vector3(Input.mousePosition.x, Input.mousePosition.y, screenSpace.z);

      //convert the screen mouse position to world point and adjust with offset

      //轉換屏幕鼠標位置到世界點,以及通過偏移調整

      var curPosition = Camera.main.ScreenToWorldPoint(curScreenSpace) + offset;

      //update the position of the object in the world

      //更新物體在世界的位置

      transform.position = curPosition;

      }

    猜你喜歡:

    1.2016程序員跳槽全攻略

    2.2016有什么好玩的手機游戲

    3.創業,我們的故事

    4.如何從零開始創業

    5.90后創業心得

    1997108 主站蜘蛛池模板: 中国国语毛片免费观看视频| 刺激videoschina偷拍| 亚洲AV综合色区无码二区爱AV| 6080yy成人午夜电影| 欧美激情一区二区久久久| 在线www天堂资源网| 亚洲精品国产v片在线观看| 99国产精品热久久久久久| 波霸在线精品视频免费观看| 国产麻豆91网在线看| 亚洲大成色www永久网址| 中国高清xvideossex| 欧美a级v片在线观看一区| 国产狂喷潮在线观看在线观看| 九九热视频精品| 超级乱淫视频aⅴ播放视频| 无人视频免费观看免费视频| 四虎免费在线观看| 一区二区三区免费精品视频 | 色九月亚洲综合网| 成人片黄网站A毛片免费| 全免费一级毛片在线播放| a级在线观看免费| 欧美极度极品另类| 国产欧美久久久精品影院| 久久亚洲精品中文字幕| 精品香蕉在线观看免费| 天天爱天天操天天干| 亚洲最大激情中文字幕| 日本三级视频网站| 日日操天天操夜夜操| 午夜性a一级毛片| 99国产精品久久久久久久成人热 | 再深点灬舒服灬太大了添学长| freehd182d动漫| 欧美成人免费全部网站| 国产女人aaa级久久久级| 两个人看的www免费视频中文| 特级aaaaaaaaa毛片免费视频 | 免费高清资源黄网站在线观看| 99久久免费精品国产72精品九九|