woong's

Unity Game 일시정지 하기 본문

Develop/Unity

Unity Game 일시정지 하기

dlsdnd345 2016. 2. 13. 20:13
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Unity Game 일시정지 하기


timeScale : 실제 시간에 대한 게임 시간

timeScale 의 기본값은 1 , 기본값 1은 실제 시간과 같다.

timeScale 을 0.5 로 하면 실제시간의 0.5배 느린 시간이 된다 .


이처럼 timeScale 을 이용해서 일시정지를 시킬수 있다 .

timeScale이 실제시간이므로 0 으로 변경해주면 실제 시간이 멈추는것을 볼수 있다 .



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
using UnityEngine;
using System.Collections;
 
public class PauseScript : MonoBehaviour {
 
    private bool isPause = true;
 
    // Use this for initialization
    void Start () {
    
    }
    
    // Update is called once per frame
    void Update () {
    
    }
 
    void OnMouseDown () {
        Debug.Log (" mouseDown" + this.name);
 
        if(isPause){
            Time.timeScale = 0;
            isPause = false;
        }else{
            Time.timeScale = 1;
            isPause = true;
        }
    }
}
 


Comments