script isnt working for gamobject

here’s my script… i want to disable the minimap when the pause menu is active and i want the minimap to activate if the pause menu is disabled and it wont work what am i doing wrong.

copyright of brayden  roberts
using UnityEngine;

public class MiniMapUi : MonoBehaviour
{
    public GameObject MinimapUi;
    public GameObject PauseMenu;

    void Update()
    {
        if (PauseMenu.activeInHierarchy == true)
        {
            MinimapUi.SetActive(false);
        }
        if(PauseMenu.activeInHierarchy == false)
        {
            MinimapUi.SetActive(true);
        }
    }
}

Use OnEnable and OnDisable.

1 Like

Make a function ShowMenu() which you’ll call on getkeydown and in that function
crunch something like
PauseMenu.SetActive (true);
IsMenuOpen = true;
and for example you can then make CloseMenu() where you set theses things to false etc :slight_smile: