button doesn't work
i have a first person game and if you press escape there should open panel that works, but the buttons don't work ... and i've remade it once it is in a canvas and in a panel ... but it doesn't really work ... the script for the button is
public void home() { SceneManager.LoadScene("HOME"); }
so there should be a panel with 3 buttons one for home, option and shop ... so I use this code to switch scenes ... I often use this code and it has never been a problem so I think that the problem isn't there...
during gameplay the camera follows the mouse and you do not see the cursor when you press escape you see the cursor again, but the camera continues to follow ... this is the code of the camera, I have a small feeling that the problem here is...
public float mouseSensitivity = 100f;
public Transform playerBody;
float xRotation = 0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
// Update is called once per frame
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * mouseX);
if (Input.GetKeyDown(KeyCode.Escape))
{
if (Cursor.lockState == CursorLockMode.Locked)
Cursor.lockState = CursorLockMode.None;
else
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = !Cursor.visible;
}
}
hopefully someone can help me, it's a pretty important part and it wouldn't be fun if it didn't work ...
Your answer
Follow this Question
Related Questions
Setting anchors in RectTransform making panel appear to vanish 1 Answer
Button custom collider 0 Answers
Problems to add an object to a scroll list 0 Answers
Have UIImages ignore orthographic size 0 Answers
How do I detect if my mouse is over UI? 0 Answers