Buttons won't enable

Hello,
After my car crush I’d like buttons to appear. Well I’ve made a script and it doesn’t work and I don’t know why. There was couple of wayes I tried to do this and any of them isn’t working as I said. First of all in script of car movement I’ve written this:

public static bool GameOver;
void OnCollisionEnter2D(Collision2D col)
    {
if(col.gameObject.tag == "Enemy Car")
        {
            Destroy(gameObject);
            GameOver = true;
        }
}

It’s working perfectly by the way.
Now in UiMenager I’ve written this:

public void Active(){
        CarMove.GameOver = true;
        foreach (Button button in buttons)
            button.gameObject.SetActive(true);
    }

And this is not working.
I’ve also tried this:

public Button button;
public void Active(){
if(CarMove.GameOver == true)
{
button.gameObject.SetActive(true);
}

Can you please help me?

Please use code tags when posting snippets of code: Using code tags properly - Unity Engine - Unity Discussions

There is no unity function “Active”. You can use either “Awake” for when the object first loads, or “Start” for just before the game starts to update, or “OnEnable” / “OnDisable” for when the component becomes enabled or disabled (“OnEnable” is also called when the gameobject becomes active and the component defaults to enabled.)

I’m kind of newbie at scripting. Can you please help me with this “OnEnable” function? What exactly should appear in code?

If you put this code on your UIManager, if you do “UIManager.enabled = true”, then this function will be called:

However it will be called when the game starts if the UIManager is already enabled when you start the game.

private void OnEnable(){
    if(CarMove.GameOver){
         foreach (Button button in buttons){
             button.gameObject.SetActive(true);
         }
    }
}