- Home /
Question by
fernandaputra45 · May 05, 2019 at 09:33 PM ·
bugfreezingpause game
Bug Playing Unity
I have bug thats make me confuse. If I hit button play on Unity, game is started but like "freeze" i must press "esc" to "unfreeze" my game and working properly.
there is any bug on my code, or what?
here is my code for GamePause
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class gamePause : MonoBehaviour {
public bool terPause;
public GameObject panelPause;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.Escape)) {
if (Time.timeScale == 1) {
pauseGame ();
}
else {
jalanGame ();
}
}
}
void pauseGame(){
Time.timeScale = 0;
panelPause.SetActive (true);
}
public void jalanGame(){
Time.timeScale = 1;
panelPause.SetActive (false);
}
}
screenshot-9.png
(505.8 kB)
Comment
Script seems fine to me. The problem might be somewhere else. Are you only using Time.timeScale in this script? If there are others that use it, then those might contain the bug.