Crashing and dont know why
using UnityEngine;
using System.Collections;
public class PauseButton : MonoBehaviour {
public Animator pauseMenu;
public bool paused = false;
public GameObject gamemanager;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (gamemanager.GetComponent<gamemanager>().gameOver)
{
pauseMenu.SetTrigger("unpause");
}
else if (Input.GetKeyDown(KeyCode.Escape))
{
if (paused)
{
pauseMenu.SetTrigger("unpause");
paused = false;
unpauseObjects();
}
else
{
pauseMenu.SetTrigger("pause");
paused = true;
pauseObjects();
}
}
}
void pauseObjects()
{
GameObject[] enemys = GameObject.FindGameObjectsWithTag("EnemyBlock");
foreach (GameObject enemy in enemys)
{
enemy.GetComponent<Rigidbody>().isKinematic = true;
}
}
void unpauseObjects()
{
GameObject[] enemys = GameObject.FindGameObjectsWithTag("EnemyBlock");
foreach (GameObject enemy in enemys)
{
enemy.GetComponent<Rigidbody>().isKinematic = false;
}
}
void OnMouseDown()
{
if (!paused)
{
pauseMenu.SetTrigger("pause");
paused = true;
pauseObjects();
}
else
{
pauseMenu.SetTrigger("unpause");
paused = false;
unpauseObjects();
}
}
}
Not sure why but this is crashing my entire editor. Feel like i been staring at it to long so im asking yall to help me find the problem. Thanks :)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612041051im_/https://answers.unity.com/themes/thub/images/avi.jpg)