Help with multi menu closing using bool

Hey all, I’m in the process of learning unity c# and I’m having trouble with menus in a tower defense game that I am making.

The problem I have is that I have lots of build platforms that spawn towers and I’m trying to stop players from being able to click on another platform while the menu is already open by closing the current/all menus that are open.

I was able to do this while only using 1 platform but I ran into problems when I added more. Should I focus on arrays, events or is there something else I need to look into in order to get my script to close multi menus?

Also note, all platforms are prefabs that the same script so I have 1 script being ran by 20-40 platforms.

The following code is on an empty game object that covers the scene and prevents the player form clicking on anything but the empty game object when a menu is open

public class closemenu5 : MonoBehaviour

{
	
public GameObject  myTower;

	public GameObject clickBlocker;

	clickmenutest script;

	void OnMouseDown () 
	{
		myTower.GetComponent<clickmenutest>().showMenu = false;

		clickBlocker.SetActive(!true);
	}

}

If more code is needed please let me know.

I was finally able to get the system to work the way I wanted it to by using FindGameObjectsWithTag.

I added the tag “tow” to each platform and used the following code

`using UnityEngine;
using System.Collections;

public class closemenu5 : MonoBehaviour 
{	
	public GameObject clickBlocker;
	clickmenutest script;

	void OnMouseDown () 
	{

		foreach(GameObject myTower in GameObject.FindGameObjectsWithTag("tow"))
		{
			if(myTower.name == "myTower")
			{
				myTower.GetComponent<clickmenutest>().showMenu = false;
			clickBlocker.SetActive(!true);
			}
	
		}

      }
}`