Preface, I have absolutely no programming experience so ELI5
And yes I’ve built the game, run the exe and the button does not work there.
It appears like it’s working, the colours change when mousing over and clicking but when it is clicked- nothing happens.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PauseMenu : MonoBehaviour
{
public void QuitGame()
{
Application.Quit();
}
}
This is what my script looks like. I attached it to a GameObject in my scene, and then attached that object to the on click event for the button.
I’ve been trying to google search an answer for a couple of hours now but I can’t get anything to work.
Edit: I tried adding a debug log and, if I’m looking in the correct place and doing this correctly, it doesn’t fire off when I click the button
As a matter of style, it’s best to centralize UI responder scripts, either to the root Canvas they belong under, or another GameObject where they can all live. Otherwise you will hate yourself trying to find them later.
Also, Application.Quit() does NOTHING in the Unity editor.
And also +1 to Magnesium’s post above. We know buttons didn’t stop working, so review what you need:
EventSystem
no “RaycastTarget” objects in front of the button
button must have a “Graphic” with RaycastTarget enabled