Button not registering click

Tried everything, the scripts are the same as in the lecture, I have assigned them to the player and the dialogue and assigned the button and the dialogue itself within the inspector. Here are some pictures. I tried setting priority on the Button in case something was covering but still not responding.

In the last picture you can see the player hooked up with the Dialogue named Firstcontact.

Even tried to create another button under ButtonRow and it did not register any mouse clicks.

1 Like

Take a look at your Fader prefab. The Fader is spawned into the DontDestroyOnLoad scene as part of the PersistentObjectPrefab, and as such, it winds up overlaying the entire screen (when it comes to UI, everything is drawn from the top of the heirarchy down, and raycast from the bottom of the heirarchy up).

On the Image component in your Fader, you will find a checkbox reading Raycast Target. Uncheck this and it will stop intercepting the mouse clicks.

Where can I find this fader object? Is the name “Fader”? Where is it exactly cant seem to spot it anywhere? Tried unchecking Raycast Target for the background picture UI but it does nothing.

If you’re using the Course project, it’s in the folder Game/Core
It’s loaded into the scene automagically by the PersistentObjectSpawner. You should be able to open the Fader and set the Raycast Target to false in the Image component.

Sorry I am not using the course folder. Is there any other course of action I can take? I have made my own game scene and following the Dialogue course alone.

Look for any UI components lower in the hierarchy than your Dialogue. A piece of UI is likely blocking the buttons and intercepting their clicks.

I have disabled the raycasters from the hierarchy and nothing :sweat: Any other thing I can try? Even attached a graphic raycaster component to the Canvas and Button Row but didnt work.

I think I’ll have to take another look at the project. Zip up your project and upload it to https://gdev.tv/projectupload. Be sure to remove the Library folder to conserve space. (I know I’ve looked before, but I don’t keep the projects, and this is a new problem in UI created after the first issue).

Upload done, sorry to trouble you so much :pensive:

Not a problem.
My apologies, though, I wasn’t able to get to this tonight as I had an appointment that ran way long, but I will get to this tomorrow after work.

Roger that no worries!

It turns out the culprit is a script in your project called MouseLook.cs

This script locks the cursor and deactivates it. When you first start the game, it looks like you have a cursor, but that is just because the game hasn’t “captured” it yet, which doesn’t happen until you click in side the Game Window. At that point, even though I cliced on Next, nothing happened because the Cursor state had already been locked and hidden. As soon as I commented out the code to lock the cursor, I could click on and interact with the dialogue…
Of course, this isn’t the intended behaviour in a 1st person game, you generally want the cursor hidden. What you can do instead is assign hot keys that each button could respond to…

What I would do is add a script to the buttons that trigger them when certain keys are pressed, for example:

using System;
using UnityEngine;
using UnityEngine.UI;

public class ButtonProxy : MonoBehaviour
    private Button button;
    private KeyCode key;
    private void Awake()
        button = GetComponent<Button>();

    public void SetKey(KeyCode keyCode)
        key = keyCode;

    private void Update()
        if (key < 0) return;
        if (Input.GetKeyDown(key))

With this script on the same script as the buttons, you can use the SetKey() method to set a key to invoke the button. For example, Next might be SetKey(KeyCode.Return), and Quit might be SetKey(KeyCode.Escape); Your choices might be SetKey(KeyCode.Alpha1+index) where index is the index of the responses you’re choosing from.


thank you very much that solves the clicking dialogue interaction!!!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms