Tuesday, August 26, 2014

Press P to Pause unity c#

iklan
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

Press P to Pause unity c#
4/ 5
Oleh