Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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.

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

C# Pause Menu Buttons not working in only 1 scene 1 Answer

Getting BCE0005: Unknown identifier: 'EditorStyles' error what is wrong with this piece of code? 0 Answers

How to make a button control Animator animation 0 Answers

unity UI button is not behaving correctly in build 0 Answers

Swap 3D model with a button 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges