Can GUI block raycasting?

Hi, I’m trying to make an rpg where you click on the ground (with a tag “Floor”) to summon a creature.
When you click on a stats window or skills window, (OnGUI) if it intercepts with the ground it will summon a creature.
The only thing I can think of is to set a boolean for when the window is open and turn it off when it’s closed, but this would make the whole floor not clickable, and the user might have to summon/want to summon with the window open, clicking somewhere without GUI.

Is there a way I can make the Raycast not penetrate the OnGUI?
Thanks - Vasir

This is what my code looks like for summoning. I’m not really sure how to tell the raycast where the GUI is. Any suggestions?

if (Input.GetMouseButtonDown (0)) {

		RaycastHit hit;
		Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);		
		if (Physics.Raycast (ray, out hit, 10.0f)) {

			if (hit.transform.tag == "Floor" && !Skill1Used && Checkpoint.CanTalk != false) {
				Skill1Used = true;
				Instantiate (Skill1, new Vector3 (hit.point.x, hit.point.y + .5f, hit.point.z), Quaternion.identity);
			}

You can assign a layer to the object you want to collide with and then only enable that layer for collision using Physics.IgnoreLayerCollision

Keep the Rect on hand that was used to define the GUI element. Before shooting your ray check if the mouse position is inside it.

if (_uiRect.Contains(Input.mousePosition))
  return;

A real implementation would of curse need to use an array and enumerate all GUI Rects in your scene.