Pause Game

Open World - Scripts - Pause Game

How to Pause Unity3D with C#

To pause the game set the timescale to 0

private float DefaultTimeScale;

PauseGame.cs 286B


using UnityEngine;

public class PauseGame
{
    private float DefaultTimeScale;
    public PauseGame(float defaultScale)=> DefaultTimeScale = defaultScale;   
    public void Pause()=>  Time.timeScale = 0; 
    public void UnPause() => Time.timeScale = DefaultTimeScale;
}
Powered by w3.css