- Home /
Show Cursor in Menu
hello I have made a menu like this (in c#):
using UnityEngine;
using System.Collections;
public class pauseMenu : MonoBehaviour
{
public GUISkin myskin;
private Rect windowRect;
private bool paused = false , waited = true;
private void Start()
{
windowRect = new Rect(Screen.width / 2 - 100, Screen.height / 2 - 100, 200, 200);
}
private void waiting()
{
waited = true;
}
private void Update()
{
if (waited)
if (Input.GetKey(KeyCode.Escape) || Input.GetKey(KeyCode.P))
{
if (paused)
paused = false;
else
paused = true;
waited = false;
Invoke("waiting",0.3f);
}
}
private void OnGUI()
{
if (paused)
windowRect = GUI.Window(0, windowRect, windowFunc, "Pause Menu");
}
private void windowFunc(int id)
{
if (GUILayout.Button("Resume"))
{
paused = false;
}
if (GUILayout.Button("Options"))
{
}
if (GUILayout.Button("Quit"))
{
}
}
}
and i want to show the cursor when im on the menu. how do i do it!?
Comment
Answer by perchik · Aug 29, 2013 at 07:38 PM
You could toggle [Screen.showCursor][1] when you're paused.
private void OnGUI()
{
if (paused){
Screen.showCursor=true;
windowRect = GUI.Window(0, windowRect, windowFunc, "Pause Menu");
}
else{
Screen.showCursor=false;
}
}
Also, you could rewrite
if (paused)
paused = false;
else
paused = true;
into
paused = !paused;
which says "paused equals the opposite of what paused used to be" so if paused was true, it becomes false, and vice versa [1]: http://docs.unity3d.com/Documentation/ScriptReference/Screen-showCursor.html
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Player movement isn't working 1 Answer
Use OnMouseEnter/OnMouse Exit with center of screen 1 Answer
Problems with pause menu displaying items and stopping player movement 2 Answers