Unity custom canvas button not registering clicks - unity3d

I have been trying for several hours to fix a button for a group project with no luck. I have the basics such as the object being a child of the canvas, graphics raycaster, button script, event system, etc.
There is no code going into this at the moment. Everything is done strictly with Unity's canvas and buttons. Upon clicking, the image should disappear, but it doesn't. The event handler does not register anything when the mouse hovers over the image.
I have looked through several posts on the Unity forum to try and find an answer that would work and none have helped.

The problem was I needed to attach a camera that would be looking at the canvas to the "event camera" of the canvas component. This can be seen in the below image.

In my case, I had rotated the image (on Canvas) to 180 degree and was trying to perform click which did not work. But as soon as I set the rotation to 0 degree the mouse click detection started working.

I had a similar issue. In my case, I had a canvas all setup, but I did not have an EventSystem in the scene graph.
Create -> UI -> EventSystem
This was the solution for me.

Related

onbuttonclick - Unity with Bolt

I am using Unity with Bolt visual scripting and having some issues. I have a 2d Mobile App and basically what I want to do is when the user touches a sprite it starts spinning on every axis. Although I am able to achieve it without the user touching the sprite from the update function.
I want to achieve this through the touch in mobile. How can I do this? There is no on-button click.
Well, I solved this by making a button and changing its image from the source image to a particular shape .png and then I was able to perform on Click Function.

In unity how to make in-game menu?

I'm making a Unity2D mobile game but I'm stuck on making a menu. I want the in-game menu and if the player touches the screen or clicks the screen, the game will start and the menu will be have store, options but I don't know how to do it. I tried to do the same scene but this time when it goes to the next level, the menu disappears. I searched on the internet but couldn't find it. Thanks.
You should first create a UIManager script for yourself.
In this script, you must define 2D elements such as Text, Canvas, Panel and provide their functionality.
Then you can control these functions in your main manager (GameManager).
To put it simply, it takes almost a video tutorial to explain it.
Because this is not a simple code error question, man.

Unity UI buttons not working at all despite having all necessary components

I can not hover over nor click on the buttons, googling I am not missing any components needed to make them work nor are there any UI components over the buttons making them unclickable. I am not sure what some possible steps to even fix this problem are. I have the event system, graphic raycaster, and all other interactables turned off during the pause menu but nothing seems to work
Button 1
Button 2
Button 3
Canvas 1
Canvas 2
Possible Cause
Eventsystem in hierarchy got deleted.
Solution
Add the eventsystem.
Unity -> Hierarchy -> UI -> Eventsystem.
Unity 2020.3.12f1
If you turn off event system then you turn off all the UI interaction, same with raycaster, the button image needs to be an active raycast target to receive the pulsation
YES!!!!!! I got it it was due to my cursor being in a locked state during game play, I just added "Cursor.lockState = CursorLockMode.Confined;" to my PauseMenu and it solved the problem

Google VR Unity SDK - Unable to Detect Touch in VR Mode

I am using GVR Unity SDK Version: 1.1 with Unity 5.5.0f3. I need to display a button similar to the Gear Icon that is rendered by the Google VR SDK. This button should accept touches and should be visible at all times. The issue with using a Button created in the Unity Canvas is that it does not process touches because the GVR Input Module takes precedence over the StandAlone input Module.
I have looked at the google vr sdk code and have found that the gear icon is rendered using OpenGL calls in the PostRender.cs file but still am not able to find where the touch is processed. Beyond this I am stuck as I dont have much knowledge of OpenGL.
My question : How do I render a button on top of the existing UI (so that it is visible at all times just like the gear icon) and get it to accept touches (by calling a function in my code).
I know that you have to do some recasting from the controller to the UI. There is a demo scene called "Scrolling UI". Try checking there to see if there is something that can help out.
I'm not a hundred percent sure, but just some advice to the right direction.
Hope you find your answer!
The simplest way I found for enabling regular touch inputs on top of the VR scene is to use a Screen Space - Overlay canvas with a regular Graphic-Raycaster and add a Standalone Input Modul to the EventSystem game object.
This way the buttons in that canvas are clickable.
Hope it helps.

simple UI menu and canvas for DK2

I am using Unity 5.1.2p3 with DK2 SDK 0.6.0.1 and I understand from this post that Screen Space - Overlay is not supported in Unity VR. It is recommended to use Screen Space - Camera (which in my case does not work) or World Space (which I am using now) but I need someone to help me understand how I get simple menu with buttons and toggles to show as a still image and how I can make selections and button presses with my mouse cursor.
I have created a menu for my app, with 4 toggles and 1 button. When I check the Virtual Reality Supported option with the Oculus being in Direct Mode and Canvas being in World Space, I can see it in VR, but I cannot see/find my mouse cursor to tick one of the toggles.
When I take off the headset, on my monitor's Game View tab, I can see and even use the mouse and select a toggle. Obviously, I have to keep the headset steady, so in my Game View, things do not shake!
Another thing I notice is that the VR camera is the same as the Main Camera in the Unity Hierarchy, but when I take off the headset and move it around, the position of the camera does not change, only looking up and down and around is reflected.
How do I simply do a static menu like a 2D surface that does not move in VR and a user can use button presses and muse clicks with the headset on? What settings are required for this way of doing UI and canvas stuff? There are 2 attachments, showing my current settings...
Are you specifically wanting to use the mouse? If you look through a blog entry I wrote below, it will show you how to use Gaze looking to trigger menu buttons:
http://talesfromtherift.com/vr-gaze-input/
You can achieve this by some code I list there that raycasts from the center of the screen and if it hits any UI, it will trigger the correct events and make it clickable by button (or by time).