Distinguish between clicks in 'game area' and on UI elements

I’m making an advance wars clone. For those of you who don’t know what that means, look at this image:

That’s what the game view currently looks like. Right now I have an input system that uses (if (Input.GetMouseButtonDown(0)) … ) to select and move elements around.

I want to add an ‘end turn’ button in the bottom corner of the play area, but I’m concerned that if I click on it, the code within my Input.GetMouseButtonDown(0) block will also run. This might, for example, cause me to simultaneously cause a selected unit to move AND end my turn, which would be bad. Is there any way to prevent this, or am I just wrong in my assumption?

Hi @brentshermana - try this

using UnityEngine.EventSystems;

    void Update() {
    if (Input.GetMouseButton(0)) {
        if (!EventSystem.current.IsPointerOverGameObject())                Debug.Log("over a UI element!");

        else Debug.Log("not over UI element!");