- Home /
Question by
Gurd123 · Mar 19, 2019 at 07:14 PM ·
c#unityeditoruser interface
UI Buttons do not click
I am using the following code to create a pause/resume system in my game which works perfectly:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PauseScript : MonoBehaviour
{
public GameObject PauseMenu;
public static bool IsPaused = false;
// Start is called before the first frame update
void Start()
{
PauseMenu.gameObject.SetActive(false);
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("escape"))
{
if (IsPaused == true)
{
Time.timeScale = 1;
PauseMenu.gameObject.SetActive(false);
Cursor.visible = true;
IsPaused = false;
}
else
{
Time.timeScale = 0;
PauseMenu.gameObject.SetActive(true);
Cursor.visible = false;
IsPaused = true;
}
}
}
}
So this checks if ispaused is true or false, if true show the pausemenu game object, which works as it should. But when i try to press any of the buttons on my UI it does not click. Here are screenshots of my hierarchy:
2019-03-19-19h09-20.png
(24.7 kB)
2019-03-19-19h10-19.png
(144.4 kB)
Comment
Your answer
Follow this Question
Related Questions
Navigate UI with gamepad 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Adding a component in editor mode by selecting an Enum. 1 Answer