zoukankan      html  css  js  c++  java
  • unity3d 事件

    1. 键盘事件

    public class keyboard : MonoBehaviour {
    
        private int pressTime = 0;
        // Use this for initialization
        void Start () {
        
        }
        
        // Update is called once per frame
        void Update () {
        
            if(Input.GetKeyDown(KeyCode.A))
            {
                Debug.Log("keyDown A");
            }
    
            if (Input.GetKeyUp (KeyCode.A)) {
                Debug.Log("KeyUp A");
                pressTime = 0;
            }
    
            if (Input.GetKey (KeyCode.W)) {
                Debug.Log("LongKeyPress Timer:" + pressTime);
                pressTime++;
            }
    
            if (Input.anyKey) {
                Debug.Log("any key LongPress");
            }
    
            if (Input.anyKeyDown) {
                Debug.Log("any keydown");
            }
        }
    }
     
    组合键思路:
          一旦玩家按下了某键后,便开启时间计时,记录一段时间内玩家的按键信息,然后与正确的比较,超时或者按错一个失败。
     
    2. 鼠标按键事件
    public class mouse : MonoBehaviour {
    
        // Use this for initialization
        void Start () {
        
        }
        
        // Update is called once per frame
        void Update () {
        
            if (Input.GetMouseButtonDown (0)) {
                Debug.Log("press down mouse left");
            }
    
            if (Input.GetMouseButtonDown (1)) {
                Debug.Log("press down mouse right");
            }
    
            if (Input.GetMouseButtonDown (2)) {
                Debug.Log("press down mouse middle");
            }
    
            if (Input.GetMouseButtonUp (0)) {
                Debug.Log("press up mouse left");
            }
    
            if (Input.GetMouseButton (0)) {
                //Input.mousePosition -->三维坐标
                Debug.Log("press long down left" + Input.mousePosition);        
            }
        }
    }

    3. 自定义事件

        自定义按键以组合的方式出现,可以设置多个按键同时影响。 Edit—>Project Setting –> input

  • 相关阅读:
    《秒杀系统架构分析与实战 》
    《豆瓣的基础架构》
    转--《亿级用户下的新浪微博平台架构 》
    转-《蚂蚁金服11.11:支付宝和蚂蚁花呗的技术架构及实践 》
    hdu2029
    hdu2027
    hdu2026(water~~)
    PHP电影小爬虫(2)
    今天来做一个PHP电影小爬虫。
    PHP Simple HTML DOM解析器
  • 原文地址:https://www.cnblogs.com/zhangweia/p/3649456.html
Copyright © 2011-2022 走看看