[Unity] 일시정지 만들기


[Unity] 일시정지 만들기

using System.Collections; using System.Collections.Generic; using UnityEngine; public class PauseManager : MonoBehaviour { private bool isPause = false; private void Update() { if(Input.GetKeyDown(KeyCode.Escape)) { if(!isPause) { SetPause(); } else { Continue(); } } } public void SetPause() { if(!isPause) { isPause = true; Time.timeScale = 0; } } public void Continue() { Time.timeScale = 1; isPause = false; } } 빈 게임 오브젝트를 하나 만들어주시고 (저는 이름을 PauseManager로 함) 위의 소스코드를 붙여주시면 됩니다 ESC를 누르면 일시정지 되고 다시...


#Unity #유니티

원문링크 : [Unity] 일시정지 만들기