Hi,
I am very new to Unity and this is my first “testing project”, and I have a problem:
I have a canvas in World Space (it is child to a cube). That contains a Panel containing a Slider.
I changed all the components to use the “none” Sprite, because I like the rectangular look.
When I try to drag the slider it usually doesn’t work (In 10 tries it worked once). Klicking on the bar works about 75% of all times, down more often than up.
Why? And how do I fix it?
Thank you
It is likely because it is having a hard time using the main camera as the event camera (the camera that resolves UI interactions)
Try creating a camera that is pointing directly at the world space camera and set it to the Canvases Event camera property, to see if that helps.
A great example of this can be found in the UI examples projet that UT provide on the asset store here: Unity Asset Store - The Best Assets for Game Making
I ran into this today and spent quite a bit of time tracking it down. For posterity, in my case the problem was that the camera’s near clipping plane was 100, and our Screen Space - Camera canvas’s plane distance was also 100. This apparently put the UI right at the edge of the clipping plane, where it mostly worked… except for slider dragging.
Changing the canvas’s plane distance to 101 (or any value larger than the main camera’s near clipping plane) fixed it.
5 Likes
For me, the problem was the slider’s Z position coordinate that was set to ~700 because of the copy->paste in Unity…
5 Likes
I just had this problem and it was because I had a background image stretched across the canvas which was marked as a raycast target. It looked like it was going under the slider but it was apparently going over it, at least for the purposes of mouse events.
For those who still have yet to find a solution let me explain. I came across this issue and came to the conclusion of the canvas not being set to Screen Space - Camera. But one issue with this though. When I’d set the canvas as such, I found out that it would ignore all my old UI elements. Which meant I had to delete them and recreate them. So I am starting to do that and it is working. Also, if you’re making an options menu, I’d recommend putting the menu in a different canvas, only if you want to form the other menus to fit in with the canvas, which I’m to lazy to do so.
I had this problem and mine was easy to fix. For some reason when i spawn the UI elements into the canvas, It placed them incorrectly. I went into scene view and noticed the slider was not flush with the canvas but far in front of it. All I had to do was move the slider closer to the canvas!
I am Prety sure it happens when your EventSystem of your UI is turned off.
The UI slider is still not draggable in the XR tool kit version 2.1.1
1 Like