how do i know if the user clicked on specific button

hello

so i have a game and its contains question with 3 options(buttons), i want my code as the following: if the user clicked on the correct answer(button) i will give him scene that’s contain specific feedback, and the same for the other answers.
i’ve been trying many solutions and nothing worked :frowning:

It’s very simple.

Everything you need is there, but if you can’t understand the doc.

You can watch this:

(quick google search and this showed up)
I suggest you learn and get used to reading docs. Makes things a lot easier.

1 Like

Simplify the behavior you want. In this case, when the user clicks a button it sends a managing script which button it was. That’s all. It does not concern itself whether the answer is correct or not, your managing script does that and reacts accordingly. So each button should call a method in the managing script and pass a value indicating which button it was (like 1, 2, 3). Use the same method for each, just change the value passed, which you can set in the Inspector Event ui.

1 Like
using UnityEngine;
using UnityEngine.SceneManagement;


public button button01;
public button button02;
public button button03;

void Start()
{
    button01.onClick.AddListener(delegate { LoadScene(1); } );
    button02.onClick.AddListener(delegate { LoadScene(2); } );
    button03.onClick.AddListener(delegate { LoadScene(3); } );
}

private void LoadScene(int sceneToLoad)
{
    SceneManager.LoadScene(sceneToLoad, LoadSceneMode.Single);
}
1 Like

thank you all you helped me a lot:)