-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path06_LifeCycle_input.cs
66 lines (45 loc) · 1.83 KB
/
06_LifeCycle_input.cs
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LifeCycle : MonoBehaviour
{
void Update()
{
if (Input.anyKeyDown) // 아무 입력을 최초로 받을 때 true
Debug.Log("플레이어가 아무 키를 눌렀습니다.");
if (Input.anyKey) // 아무 입력을 받으면 true
Debug.Log("플레이어가 아무 키를 누르고 있습니다.");
// 각 입력 함수는 3가지로 구분 (Down, Stay, Up)
// GetKey: 키보드 버튼 입력을 받으면 true
if (Input.GetKeyDown(KeyCode.Return)) // Return == Enter
Debug.Log("아이템을 구입했습니다.");
if (Input.GetKey(KeyCode.LeftArrow))
Debug.Log("왼쪽으로 이동 중");
if (Input.GetKeyUp(KeyCode.RightArrow))
Debug.Log("오른쪽 이동을 멈추었습니다.");
// GetMouse: 마우스 버튼 입력을 받으면 true
if (Input.GetMouseButtonDown(0)) // 0: 왼쪽, 1: 오른쪽
Debug.Log("미사일 발사!");
if (Input.GetMouseButton(0))
Debug.Log("미사일 모으는 중..");
if (Input.GetMouseButtonUp(0))
Debug.Log("슈퍼 미사일 발사!!");
// GetButton : Input 버튼 입력 받으면 true
if (Input.GetButtonDown("Jump"))
Debug.Log("점프!");
if (Input.GetButton("Jump"))
Debug.Log("점프 모으는 중..");
if (Input.GetButtonUp("Jump"))
Debug.Log("슈퍼 점프!!");
// GetAxis : 수평, 수직 버튼 입력을 받으면 float
if (Input.GetButton("Horizontal")) {
Debug.Log("횡 이동 중.."
+ Input.GetAxisRaw("Horizontal")); // 가중치 X, GetAxisRaw: 가중치 O
}
if (Input.GetButton("Vertical"))
{
Debug.Log("종 이동 중.."
+ Input.GetAxisRaw("Vertical"));
}
}
}