How to null controls while in Pop up UI

Hello everyone, i was just wondering if someone might be able to point me in the right direction on how to accomplish this. i have 6 triangles in my game. it is a single scene game. They are all tagged with “TriangleP”. They also have Box Collider 2D. i created a script to randomize which triangle is assigned to a moving script (from itween). The objective is to click on the moving triangle. I have created 3 pop up UI’s, a 3 second countdown UI, a “Correct” Pop up UI for when you get it right, and lastly an “Incorrect” Pop up UI for when you got it wrong. My problem is that even during the 3 second countdown Pop up UI, i can still click in the background to beat the game, and the same goes for the Correct and Incorrect Pop up UI’s, even if i am already correct i can still click on a non moving object and get an incorrect despite the fact that the player has already beaten the game, is there any way to null the controls while the Pop ups are active.

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class ClickObject : MonoBehaviour {
[SerializeField]
private GameObject NextLevelUI;
[SerializeField]
private GameObject TryAgainUI;

	void  Start (){

	}

	void  Update (){


	
		RaycastHit2D hit;


		if(Input.GetMouseButtonDown(0)){

			hit=Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition) , Vector2.zero);
			if (hit.collider != null){
				TryAgainUI.SetActive(true);
				if(hit.collider.GetComponent<MoveSample>()!= null && hit.transform.gameObject.tag=="TriangleP"){
					NextLevelUI.SetActive(true);
					TryAgainUI.SetActive (false);{
						Debug.Log("SUCCESS");

					}
				}

			}
		}
	}
}

Any help would be greatly appreciated, i am new to coding so if i am way off don’t judge lol

I assume that you are using the new Unity UI (and not the old OnGUI). In this case, you can use EventSystem.current.IsPointerOverGameObject to test whether the mouse is currently positioned above any UI element.

For example, add the following line at the start of your Update loop:

if (EventSystem.current.IsPointerOverGameObject()) return;

PS: You should make it a habit to clean your scripts from unneeded functions like the empty Start(). They DO drain performance (this is not so important with Start(), but any left-over Update() function can add up quickly. Its very sad that Unity still has this harmful default script created with an pre-implemented Update loop. Even their own trainers complain about this regularly in their training videos…)