- Home /
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.
How to bring the menu options? Menu options are in a separate game object with animation in it.
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))
{
}
}
}
Answer by Kiwasi · Aug 19, 2014 at 07:20 AM
There are multiple ways to code a menu
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.
Build a menu using 2D sprites or GUITextures. Use OnMouseDown or raycasts to detect clicks. This is pretty much the way you are going
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.
Thanks. But am struck with this Time scale. Am not sure How to pause the game and bring the menu which has an options for resume, options and back. Also, when I use Time Scale the complete game freezes, So how can I play that $$anonymous$$enu Animation? It is frustrating as I have not came across with any solution yet!
Update still runs. You can use Time.unscaledDeltaTime and a custom timer.
Scratch that, try the new Unity 4.6 beta. Every property you want to play with can be controlled via the animator.
Wow Sounds great. So even if Timescale is zero, I can able to animate particular game object?
Answer by DBar · Aug 19, 2014 at 07:11 AM
RayCast is not expensive. You need it.
Where's your menu?
Thanks. What do you mean by menu? It is just a plain with texture.
All I need is how to instantiate the menu when I hit the pause button. I do understand that we need to use Time scale for pausing the game! But, it freezes the completed game so I cannot instantiate the menu. Any suggestion?
Your answer

Follow this Question
Related Questions
canvas screen space camera rotation issue 0 Answers
Galak Z like UI element 0 Answers
Stop character from moving out of camera sight 1 Answer
UI Canvas with split Camera 0 Answers
Player UI freezes when rendering to render texture. 1 Answer