Input Limiting

Currently I have a system setup for the player to place various rooms in a play space, much like a tower defense game. The room follows the mouse and stops once the player clicks. This aspect functions fine.
My issue is with handling other clicks while the room is following the mouse, specifically when a button is clicked on the UI. In this case the button is fired and the room is dropped. Is there some way for the button to be prioritized and be the only one to receive input?

I am currently getting input with Input.GetButtonDown

EventSystem.IsPointerOverGameObject can help determining if you are over the UI. However, I remember it not always working the way I expected. In that case, possibly EventSystem.alreadySelecting could help, or you could override the OnMouseEnter() / OnMouseExit() / OnMouseOver() of the script of your game object where you place the rooms.

Finally, a conceptual workaround: maybe interaction with the UI should be not allowed while placing a room, marking it non-interactable or maybe even hiding it? CanvasGroup.interactable on a root UI object makes this easy.