# unity 中基本类的使用

  1. 鼠标键盘
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    //鼠标
    if (Input.GetMouseButtonDown(0))
    {
    Debug.Log("按下了左键");
    }
    else if (Input.GetMouseButtonDown(1))
    {
    Debug.Log("右键");
    }
    //持续按下
    if (Input.GetMouseButton(0))
    {
    Debug.Log("持续");
    }
    //抬起鼠标
    if (Input.GetMouseButtonUp(0))
    {
    Debug.Log("抬起");
    }

    //键盘按下
    if(Input.GetKeyDown(KeyCode.A))
    {
    Debug.Log("A");
    }
    //持续
    if (Input.GetKey(KeyCode.S)) {
    Debug.Log("S");
    }
    //抬起
    if (Input.GetKeyUp(KeyCode.D)) {
    Debug.Log("d抬起");
    }

  1. 手机平板
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    void Start()
    {
    //开启多点触摸
    Input.multiTouchEnabled = true;
    }

    // Update is called once per frame
    void Update()
    {
    //判断单点触摸
    if(Input.touchCount ==1)
    {
    Touch touch = Input.touches[0];
    Debug.Log(touch.position);
    switch (touch.phase) {
    case TouchPhase.Began:
    break;
    case TouchPhase.Moved:
    break;
    case TouchPhase.Stationary:
    break;
    case TouchPhase.Ended:
    break;
    case TouchPhase.Canceled:
    break;
    }
    }

    //判断多点触摸
    if(Input.touchCount == 2)
    {
    Touch input_tch = Input.touches[0];
    Touch touch = Input.touches[1];

    }
    }

  1. 灯光的使用