Pause Button Brings down a menu options! help needed!

When pause button is touched it need to brings down the menu options which already has the options for Resume, Try again.

Am able to pause the game by using timescale.

  1. How to bring the menu options? Menu options are in a separate game object with animation in it.
  2. Am currently using Ray cast for touching function is it a good option? I guess if I use ray cast it will be expensive in terms of memory is there any other better way to approach it?

Code:

{
	public RaycastHit hit;
	public Texture pauseTex;
	public Camera cam;

		
	void Update()
	{
		if (Input.GetKeyDown (KeyCode.Mouse0)) 
		{
			control (Input.mousePosition);
		}		
	}


	void control (Vector3 a)
	{
		Ray ray = cam.ScreenPointToRay(a);

		if (Physics.Raycast (ray, out hit, 20)) 
		{

		}
	}

}

There are multiple ways to code a menu

  1. Use Unity’s built in system OnGUI(). This is notorious for bad performance, and is relatively inflexible. But its pretty easy to code a menu.
  2. Build a menu using 2D sprites or GUITextures. Use OnMouseDown or raycasts to detect clicks. This is pretty much the way you are going
  3. Use a third party tool available from the asset store. I hear NGUI is pretty good, though I have never used it.

For a pause menu performance is not really a big concern. All of your big performance hitting scripts should be idle during the pause. Menus and GUI that need to operate during gameplay are where performance should be considered.

RayCast is not expensive. You need it.

Where’s your menu?