So I have got a script here that is meant to open a pause menu but it comes up with an error whenever I put it in my game. I am relatively new to unity though so its probably an easy fix.
Here is the script.
using UnityEngine;
using System.Collections;
using UnityStandardAssets.Characters.FirstPerson;
public class PauseGame : MonoBehaviour {
public Transform canvas;
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Escape))
{
Pause();
}
}
public void Pause()
{
if (canvas.gameObject.activeInHierarchy == false)
{
canvas.gameObject.SetActive(true);
Time.timeScale = 0;
Player.GetComponent<FirstPersonController>().enabled = false;
}
else
{
canvas.gameObject.SetActive(false);
Time.timeScale = 1;
Player.GetComponent<FirstPersonController>().enabled = true;
}
}
}
Here is a picture as well