Prevent menu spawner object from instantiating a menu again if the menu close button is on top of the object


I have an interactable object that spawns a menu on top of it when clicked, this is it’s code:

private void OnMouseUpAsButton()
{
    RadialMenuSpawner.ins.SpawnMenu(this);
}

the menu contains several Images that should change a variable of the object and close (destroy) the menu, the problem is that when I click on one of them to close it, the menu opens again (I’m thinking it’s because i have the menu image on top of the object), here is the image script:

public void Update()
{
    if (Input.GetMouseButtonDown(0))
    {
        if (selected)
        {
            Debug.Log(selected.title + " was selected");
        }

        Destroy(gameObject);
    }
}

Is there a way to prevent this kind of behaviour?
I want to be able to close the menu and open it again but not on the same mouse click, I tried changing the MouseDown to MouseUp but then the menu doesn’t show up at all (maybe opening and closing on the same frame idk).


Okay i finally found a weird solution trying some things, i just made a boolean variable that tells the spawner to wait one more click after deleting the menu, that worked fine but sometimes you had to click two times to spawn another menu so i made an OnMouseEnter function that controlled the boolean variable too so you had to actually move you mouse outside the game object and then move it again in the object and that is quite a bit what I wanted so i will mark this as solved