• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Vayl · May 11, 2018 at 02:38 PM · unity 5buttonsuser interfacepause menu

UI buttons not detecting mouse click/mouseover

So I've implemented a pause menu following some tutorials, however the menu seems to be completely unable to detect the mouse at all, including left click.

What's 'meant' to happen is the buttons darken when hovered over, and then darken moreso when clicked on, however they just always appear dark, and nothing happens when they're clicked on.

Looking at other people with this issue I have double checked I have an Event System, and that everything's on one canvas.

I've attached some screenshots that'll hopefully help out.

Note a lot of the stuff on the UI is a fellow Student's work, so forgive the lack of organisation, I've tried disabling his components and it still doesn't work sadly.

Here's the code for the pause menu:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class PauseMenu : MonoBehaviour
 {
 
     public static bool gameIsPaused = false;
 
     public GameObject pauseMenuUI;
 
     CursorLockMode desiredMode;
     
     void Update () {
         if (Input.GetKeyDown(KeyCode.Escape))
         {
             if (gameIsPaused)
                 Resume();
             else
                 Pause();
         }
     }
 
     public void Resume()
     {
         pauseMenuUI.SetActive(false);
         Time.timeScale = 1f;
         gameIsPaused = false;
         Cursor.visible = false;
         desiredMode = CursorLockMode.Confined;
     }
 
     void Pause()
     {
         pauseMenuUI.SetActive(true);
         Time.timeScale = 0f;
         gameIsPaused = true;
         Cursor.visible = true;
         desiredMode = CursorLockMode.None;
     }
 
     public void Quit()
     {
         Debug.LogWarning("Game quits if not in Unity editor");
         Application.Quit();
     }
 }
resume-button.png (57.4 kB)
canvas.png (59.4 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Vicarian · May 11, 2018 at 02:55 PM

On your Canvas Group component, Interactable is disabled. Check that to enable it and events should process.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vayl · May 11, 2018 at 03:47 PM 0
Share

@Vicarian Thanks! That fixed the first issue, but now back with a new one.

So in some magical twisted turn of events, now when I -click- the resume button ins$$anonymous$$d of pressing escape to resume, the camera detaches itself from the player.

Pausing and unpausing again using escape seems to fix said issue, but whenever I resume with a left click the camera dies.

EDIT:

So the issue is that I was disabling the camera rotation when the game was paused. As this is done in the camera script and not the pause menu script like the rest of the code was, I was stupidly making a second bool in the Camera orbit script, with it switching states on the press of the escape button.

I'll fix this by having it switch depending on what gametime is. As when the game pauses gametime goes to 0f.

avatar image Vicarian Vayl · May 11, 2018 at 04:00 PM 0
Share

You assign CursorLock$$anonymous$$ode to a var, but you don't actually set it:

 Cursor.lockState = desired$$anonymous$$ode;
avatar image Vayl Vicarian · May 11, 2018 at 05:16 PM 0
Share

Ah yeah, I was planning to lock the cursor to the screen while the game is playing, but forgot to properly test it and moved onto other things. Thanks once more! :)

avatar image Kaldrin · Nov 16, 2020 at 07:06 PM 0
Share

Exactly! For me I also needed to check "Block raycast" for it to work

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

227 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Calling functions via buttons when cooldown finished 1 Answer

Problem with Application.LoadLevel 0 Answers

Deleting virtual buttons in vuforia unity ar. 1 Answer

Highlight Button not working 1 Answer

Pause menu not working with custom player controller 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges