Unity UI Resume Game button is unclickable - unity3d

So i have been trying to create a pause menu for my project, however the resume button is un-clickable (the same i believe for another button on this menu). The event system does not show anything when hovering over this button or attempting to click it.
Screenshot of Event System not showing button object
The button itself is set to interact-able and has the button's image as it's target graphic. The canvas it is also placed on also has the Graphic Ray-caster component attached. I also do not believe that there is any UI object covering the button preventing it from being clicked.Screenshot of Pause Menu UI as seen from scene view to show no blocking objects I am making use of the first person character controller starter asset by unity as well as the new input system.
I am unsure as to what could be causing this, I have also tried locking the cursor of the starter asset inputs.
Any advice would be greatly appreciated.

Related

UI Button doesn't disappear when deactivating parent in hierarchy

I'm trying to write a simple main menu page with this hierarchy:
MainMenu (an empty game object)
↳ Canvas
↳ PlayButton (a TextMeshPro Button)
I want the button to deactivate the 'MainMenu' object in the hierarchy when clicked, thus hiding its Canvas child and the Button along with it. To do this, I'm providing the MainMenu object reference to the Button's OnClick() callback and calling 'GameObject.SetActive' to false when clicked.
My problem is that when I click the button, the MainMenu hierarchy get grayed out in the editor but the Button sticks around with its yellow Highlighted color shown. It does disappear if I change the display resolution while still in Play mode (maybe forcing a refresh?), but I can't figure out why deactivating the MainMenu wouldn't make it refresh in the same way.
I've tried calling SetActive(false) on the PlayButton and the Canvas themselves- I also tried setting enabled = false on them, but the Button appearance behaves the same. From everything I've read, calling SetActive(false) should hide whatever gameObject I call it on, so I can't figure out what I'm missing.
Alright, found my own mistake. The Camera's Clear Flags setting was Don't Clear, so even calling Destroy(gameObject) on it didn't remove it from the screen.
Setting the Camera to use ClearFlags: Solid Color fixed the problem.
It looks to me like you have a button in your grid that is displaying. When the game is playing, after you click to turn off the button, go to the scene tab, click the yellow button and see where that object is.
If in doubt (For testing purposes only) delete the button on click and if you see something else then it is obviously not that button.

My button Not responding on Hover or Click in Unity 2D UI

Ok as you read title you will know problem. The problem is very old and much people tell fixes. But nothing works for me. So please help another time. I have EventSystem in hierchy. See picture
Let me show you my canvas picture of inspector
As you can see I have other Canvas so let me see you picture of that name "Shop Canvas"
My EventSystem in inspector
Panel of buttons in Inspector
And finally button in inspector(These 2 images for buttons because button in inspector is some long).
If you need more Info right below and I will edit the post. Thanks for your help
I had a similar issue of not being able to engage with a button. The reason being there was another UI component with ray cast enabled that did not allow inputs to reach the button.
For your case, I think it's the "The things...". Try disabling that and see if you can engage with the button again.
I had a similar issue, where I couldn't see button interactions in a scroll view. I eventually created a click event (which worked) to find the source of my problem. While it wasn't a Raycast problem, someone else might find this handy (or I will see it in the future!)
Mine (an issue I've accidentally 🤦‍♂️ created in the past) was that I set the color of the attached Image component to black and couldn't see the interaction states in the Button. So to restate, leave Image.Color white/opaque but change button states if you want dark menus.

NSButton in Swift, handle click and release events

i'm trying to manage different state of a simple push button on an OS X application : When the user click on it, and when the user release the click.
Currently i set my button type by NSMomentaryLightButton
NSMomentaryLightButton When the button is clicked (on state), it
appears illuminated. If the button has borders, it may also appear
recessed. When the button is released, it returns to its normal (off)
state.
This type of button is best for simply triggering actions because it
doesn’t show its state; it always displays its normal image or title.
This option is called Momentary Light in Interface Builder’s Button
inspector
I thought it was the good way, but when i print my button status, it's like a toggle button than the push button that i set. As you can see on exemple gif
To sum up, How can i have a real push button behaviour ? Call function when the user click on it, and when the user release the click.
Thank,
You don't want to use buttons for piano keys. First, they are non-rectangular, and they don't act as buttons do: neither single-action push-button, nor toggle switches. You are interacting in a custom way, with a custom view, meaning the NSButton control hierarchy isn't called for. Instead you're subclassing NSView and capturing low-level mouse events as detailed here:
https://developer.apple.com/library/prerelease/content/documentation/Cocoa/Conceptual/EventOverview/HandlingMouseEvents/HandlingMouseEvents.html#//apple_ref/doc/uid/10000060i-CH6-SW1
You found this yourself as you detailed in your own comments, but I wanted to make sure you had a higher level point of view. It's even possible, and probably best, to consolidate all of the piano keys into a single view, and let the keys themselves be rendered using NSBezierPath and perform mouse hit detection using containsPoint:
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSBezierPath_Class/#//apple_ref/occ/instm/NSBezierPath/containsPoint:
This is a lot more work but the only way to make a truly professional looking piano simulation. Then you can render the keys with whatever outline, fill, and labeling you need without the limitations of built-in button shapes and layout. You could even have the bottom edges of the keys slightly rounded, for example, or apply a shiny texture.

Unity UI button not reacting to clicks or hovering

I'm using Unity 3D's new UI system to build a pause menu for my game. Currently I'm trying to have my buttons respond to mouse clicks. Some of my hierarchy is as follows:
When I click on one of my buttons in-game nothing happens, this includes a lack of button animation that should occur when hovering. My "Main Canvas" gameobject contains the following components:
I have already ensured that my Image component has "Raycast target" checked and that my Button component has "Interactable" checked.
Could this be because my Canvas' render mode is in screen space (camera)? I need the render mode to be set to this because I have 3D models that are added in front of the UI during gameplay.
Things I have already tried / checked:
Ensured that an EventSystem was present
Checked that another UI element wasn't covering the buttons, preventing a raycast
Ensured that the camera rendering the UI is above my main camera that is attached to the player. The rendering UI camera has a layer of 1 while the player camera has a layer of 0.
Your EventSystem GameObject is missing the Standalone Input Module Script component.
Select your EventSystem->Add Component ->Standalone Input Module. Done!
The gif below decsribes two ways to do that.
If anyone here ever runs into this problem and none of these fixes work, go to Edit > project settings > Input, then in the inspector tab click the little gear icon in the top right corner and click Reset. this should fix all your buttons!
Ensured that EventSystem component is present in the hierarchy. Without EventSystem unity is not able to track any events that's occurring in the particular scene
Try to change short order in canvas. Maybe the button canvas is blocked by another canvas.
If anyone here ever runs into this problem and none of these fixes work:
Chose your button in Hierarchy -> Find "Canvas" in Inspector -> Delete IT(Remove component)!
If you´re using the InputSystemPackage go to Edit > ProjectSettings > Input System Package. And in supported devices make sure there´s a Mouse option, if not, press the + button below and add the mouse device.
If you are pausing the game by setting the timescale to 0, then no input will work if the update mode of the input system is set to process events in Fixed Update, since the fixed update is not run at zero timescale - you can change the update mode in Edit > ProjectSettings > Input System Package.
Input settings screenshot
For me it was because the button was covered by other components in the Canvas. I changged put the button in the very front whithin the campus, and it works now
Please check for the "EventSystem" to be present in Hierarchy to make button working.
refer the attachment for it
I had this same problem in Unity v2020.3.24f1, and after trying all suggestions to no avail I noticed in my case the Graphic Ray-casting was un-checked. Just in case somebody tried everything and is still facing this issue, make sure it is ticked in the canvas element!.
Had a similar issue, my event system already had the Standalone Input Module attached and I apparently followed the warning and replaced it with Input System UI Input Module which broke mouse events. Adding the standalone Input module back isn't enough, the other input module must be disabled or removed. So try using the Standalone Input Module exclusively in your event system.

Unity new UI button click able outside of button area, non clickable over button area

I have created new UI button in empty scene,
Whenever I click on button its not click-able , but when I take cursor slightly above the button area and click, it gets clicked.
I guess Something like offset problem occurring?? Any fix to that?
NOTE I have tried creating new scene same result
,also created new project though Same result.
Did you check the EventSystem gameObject, it displays which UI element you are hovering, and other useful information.
After lot of trial and errors, reinstalling Unity did the job