Trying to activate a GUI when a tile is clicked

My goal currently is to make a tile in my game that when you click on it, it opens up a GUI that allows you to click on a unit type and it spawns on the tile. I’m not too experienced at writing my own code so I am currently strugling with this. This is the code I have so far

using UnityEngine;
using System.Collections;

public class FactorySpawner : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		if(Input.GetKeyDown(KeyCode.Mouse1){
			OnGUI();
		}
	}

	void OnGUI(){
		Rect rect = new Rect (10, Screen.height - 875, 130, 120);
	}
}

Not to rub off at all m8, but if you are putting the gui in an update function you need to learn a bit more to complete custom scripts. Just like void update, void ongui is already called.

Here is some make up code of how it should work

Private bool showUnitMenu;

Void Update()
{
If(Input.GetMouseButtonDown(0))
{
showUnitMenu = true:
}
}

Void OnGUI()
{
If(showUnitMenu == true)
{
GUI.Box(new rect(0,0,Screenwidth,20), “unitBox”);
}

Sorry if theres errors i type this on my phone. You get the general idea though

-Brett