zoukankan      html  css  js  c++  java
  • [原]解决Unity3D导入的3D(3DsMAX)模型不能响应鼠标事件

    原因:

    在Unity3D中,导入的3D模型默认不能响应鼠标事件,原因是没有启动碰撞机(Collider)。


    解决:

    在Project窗口选中导入的模型(.FBX),在Inspector窗口中,确保"Generate Colliders"项被选中


    而后,该模型对应的对象就可以响应鼠标事件,如下代码

    void Update () {
        if( Input.GetKey( KeyCode.W ) ){
            transform.Translate( Vector3.up * Time.deltaTime * speed );
        }
        if( Input.GetKey( KeyCode.S ) ){
            transform.Translate( -Vector3.up * Time.deltaTime * speed );
        }
        
        if( Input.GetKey( KeyCode.A ) ){
            transform.Translate( -Vector3.right * Time.deltaTime * speed );
        }
        
        if( Input.GetKey( KeyCode.D ) ){
            transform.Translate( Vector3.right * Time.deltaTime * speed );
        }
        
        if( Input.GetKey( KeyCode.Q ) ){
            transform.Rotate( -Vector3.up * Time.deltaTime * speed );
        }
        
        if( Input.GetKey( KeyCode.E ) ){
            transform.Rotate( Vector3.up * Time.deltaTime * speed );
        }
    }
  • 相关阅读:
    javaScript快速入门
    解决编程式路由往同一地址跳转时会报错的情况
    babel 依赖
    路由拆分可以达到一定程度的性能优化
    正则的扩展
    设计模式
    mysql数据库
    php基本语法
    事件循环
    面向对象编程
  • 原文地址:https://www.cnblogs.com/basecn/p/3264296.html
Copyright © 2011-2022 走看看