Game manager is broken

Its getting pretty late where i am so can we continue later?

Yes, of course. This is a forum, not live support where people are actively waiting for your answer. Come back when you have time. :slight_smile:

If you don’t reply within 20 days, it might be, though, that the thread gets closed. If you want to reopen it, please message one of us teaching assistants. We are usually able to open threads again.

1 Like

I don’t understand?

There are three dots in the Button component box. Click on them. Then click “Remove component”.

Then click “Add Component” and readd the Button component. Then reassign the game object with the GameManager component.

It still doesn’t work

Could you please share a of your Console window? And of the Inspector of the GameManager game object? And could you also share your code as formatted text?

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.SceneManagement;

public class GameManager : MonoBehaviour

{

Quiz quiz;

EndScreen endScreen;

void Start()

{

    quiz = FindObjectOfType<Quiz>();

    endScreen = FindObjectOfType<EndScreen>();

    quiz.gameObject.SetActive(true);

    endScreen.gameObject.SetActive(false);

}

void Update()

{

    if(quiz.isComplete)

    {

        quiz.gameObject.SetActive(false);

        endScreen.gameObject.SetActive(true);

    }

}

public void OnReplayLevel()

{

    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);

}

}

Thanks. Your code looks fine. Since OnReplayLevel is public, you should be able to select it in the dropdown menu. Theoretically.

Now check which game object has got this GameManager component assigned. Then click the OnClick field once to see if the field references. Theoretically, the referenced game object should get highlighted in your Hierarchy. Is it the one with the GameManager component?

Nothing gets highlighted. I left clicked the On Click field once and the On Click field was the only thing that got highlighted.

I FIXED IT. I was assigning the game manager script when i was supposed to assign the game object. :fireworks: :sparkler: :tada:

Good job! :tada:

1 Like

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

Privacy & Terms