본문 바로가기
개발/C#

유니티 C# 일시정지 Pause 구현하기 간단 사용법

by SPNK 2022. 7. 6.
반응형
  • 코드 작성
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Example : MonoBehaviour
{
    bool isPause = false;

    void Awake()
    {
        Time.timeScale = 1;
    }

    public void Pause()
    {
        if (!isPause) //정지됨
        {
            isPause = true;

            Time.timeScale = 0;
        }
        else //해제
        {
            isPause = false;

            Time.timeScale = 1;
        }
    }
}

 

반응형

댓글