Tuesday, 26 August 2014

Press P to Pause unity c#

using UnityEngine;
using System.Collections;

public class Pauser : MonoBehaviour {
private bool paused = false;

// Update is called once per frame
void Update () {
if(Input.GetKeyUp(KeyCode.P))
{
paused = !paused;
}

if(paused)
Time.timeScale = 0;
else
Time.timeScale = 1;
}
}

1. Create one empty game object.
2. Attach script component to that game object.
3. Copy and paste above code on that script.
4. Play & Cheack

No comments:

Post a Comment