Cannot select 'OnReplayLevel' method on button 'On Click'

When I drag the QuizManager object into the button On Click i do not get the OnReplayLevel() method in the dropdown menu. Here is the screenshot from the button properties:

button_onclick

And here is my GameManager.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class GameManager : MonoBehaviour
{

    [SerializeField] Quiz quiz;
    [SerializeField] EndScreen endScreen;

    void Start()
    {
        quiz.gameObject.SetActive(true);
        endScreen.gameObject.SetActive(false);
    }

    void Update()
    {
        if (quiz.isComplete)
        {
            quiz.gameObject.SetActive(false);
            endScreen.gameObject.SetActive(true);
            endScreen.ShowFinalScore();
        }
    }

    public void OnReplayLevel()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    }
}

2 Likes

Hi,

Welcome to our community! :slight_smile:

Did you assign the game object with the GameManager component to the field? Assigning the script itself will not show you the OnReplayLevel method.


See also:

That was it. Thank you very much!

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

Privacy & Terms