본문 바로가기
[ Unity ]/- 유니티 실습

유니티 PauseMenu

by MRG 2024. 9. 18.
728x90
반응형

 

▣ 코드 설명
Time.timeScale: 게임의 시간 흐름을 조정하는 변수로, 0으로 설정하면 게임이 멈추고, 1로 설정하면 정상 속도로 돌아옵니다.
pauseMenuUI: 게임 오브젝트로 설정된 메뉴 UI를 나타냅니다. 이 UI는 Canvas 안에 있는 메뉴 버튼들로 구성될 수 있으며, SetActive() 메서드를 사용하여 활성화하거나 비활성화할 수 있습니다.
isPaused: 게임이 일시 정지 상태인지 확인하기 위한 불리언 변수입니다.
Input.GetKeyDown(KeyCode.Escape): Esc 키가 눌리면 일시 정지 또는 재개 동작을 실행합니다.
Resume(): 게임을 다시 시작하는 함수입니다. pauseMenuUI를 비활성화하고 Time.timeScale을 1로 설정해 시간 흐름을 정상으로 되돌립니다.
Pause(): 게임을 일시 정지하는 함수입니다. pauseMenuUI를 활성화하고 Time.timeScale을 0으로 설정하여 게임의 시간 흐름을 멈춥니다.

 

https://docs.unity3d.com/ScriptReference/Time-timeScale.html

 

Unity - Scripting API: Time.timeScale

This can be used for slow motion effects or to speed up your application. When timeScale is 1.0, time passes as fast as real time. When timeScale is 0.5 time passes 2x slower than realtime. When timeScale is set to zero your application acts as if paused i

docs.unity3d.com

https://docs.unity3d.com/ScriptReference/GameObject.SetActive.html

 

Unity - Scripting API: GameObject.SetActive

A GameObject may be inactive because a parent is not active. In that case, calling SetActive will not activate it, but only set the local state of the GameObject, which you can check using GameObject.activeSelf. Unity can then use this state when all paren

docs.unity3d.com

https://docs.unity3d.com/ScriptReference/Input.GetKeyDown.html

 

Unity - Scripting API: Input.GetKeyDown

Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close

docs.unity3d.com

 

 

728x90
반응형

'[ Unity ] > - 유니티 실습' 카테고리의 다른 글

유니티 3D 카메라 3인칭, 1인칭 Player 이동 Mode  (8) 2024.09.21
유니티 Camera Following  (1) 2024.09.19
유니티 Loading Scene  (8) 2024.09.18
유니티 GameSettingsUIManager  (1) 2024.09.17
유니티 Camera Shake  (0) 2024.09.15

댓글