- Home /
UI Sliders not interactable
Hi
I have a slider in my scene that it supposed to turn the volume up and down, but I can not interact with the slider at all. The interactable checkbox is ticked so it should work, but it doesn't.
Does anyone have an idea why this is happening and how I can fix it?
Do you have an EventSystem gameobject in your hierachy too? When you add UI stuff Unity automatically adds an EventSystem if there's non in the scene, but only when you do it in the editor. If you add a Slider at runtime the EventSystem won't me created.
Also, do you have anything else that could be over the slider? Note that an image with alpha 0 over your slider will also block the events.
There is an event system in the scene that I use for a few other UI elements and I'm 100% sure there's nothing blocking the slider.
Can we have a screenshot of your hierarchy around the slider (+ slider's inspector) ? $$anonymous$$ake sure there is no other UI panel/image/... over your slider, you can only interact with the top layer of your canvas (ie the last sibling in most of the cases)
Here's a screenshot. http://i.gyazo.com/73b8a981b605d070f7b73a58cf3dfa3b.png Nothing in the canvas is active at the moment except the slider. But not only sliders, toggle boxes and button don't work either when added.
Sliders and Buttons can get Blocked by UI Elements that get Drawn in front.
If I look at your screenshot it seems like a text Element has found it's was in front of the Slider, rendering it unusable.
Reorder your Elements, so that the Slider is in front of the rest or try to avoid overlapping UI Elements that should be on a equal Layer.
UI Elements inside Canvas, Panel, etc. are order from bottom to top, the one at the bottom gets renderer in front of everything else, no matter what position you set in the Rect Transform.
Answer by apple92 · Apr 13, 2015 at 02:43 PM
Well for everyone else having the same problem.
Check the following things:
Is any other UI Element blocking my slider/button?
Does any parent element have a canvas group with interactable false?
Are there any hidden (Alpha 0) Elements blocking my slider/button?
Is there an Event System in the Scene?
Does the button work in a newly created Canvas?
Working through this list while keeping in mind that, UI Elements inside Canvas, Panel, etc. are ordered from bottom to top (the one at the bottom gets renderer in front of everything else), should solve most of the problems.
Thank you. I did not know an Event System was needed.
Had the same problem and the issue was that the UI element was too far in the negative on the Z axis. when I set it to 0 it started working again...
Thank you for your advice! Your last point helped me. I moved my slider towards the bottom of the list inside the Canvas and it started working!
Answer by the_lemur · Sep 13, 2016 at 07:34 PM
Had this problem. Had to change the Canvas to Screen Overlay instead of Camera space.
I don't know if it's because the original prefab was created in that space, or if it's universal. Not going to test just this moment.
Changed $$anonymous$$e to overlay and it worked, this is ridiculous, sliders should work on any kind of canvas
Answer by Max_Bol · Sep 21, 2016 at 06:43 PM
The most common reason why a slider or a button isn't intractable is because there's a overlapping UI element with "Raycast Target" activated over it. By default, that option is always activated for every new visible UI element added in the scene. (Only copied element with the option ticked Off aren't created with it On.)
For example, you might use a full screen 100% transparent UI image for you screen transition that allow you to turn the screen white, black or any color of your choice when switching screen. If that has the (as it is by default) "Raycast Target" activated, no UI element with either lower priority or behind it (varying the type of canvas) will be working from the mouse interaction (as it will block its raycast calls).
Sometimes, it can also be the type of font you're using. In an option menu for example, you might put thing in a dynamic way that allow it to adjust itself for such thing as different orientation (smartphone/tablets) and different screen ratios (PC/Consoles). At some point, maybe you got a text UI element that with "Raycast Target" on that is hovering above the slider, but as the font is slightly off to the bottom of its "space", you only will see it by looking at the Scene while selecting the Text element (with its box size).
If you're working on a flat canvas (anything else than "WorldSpace"), the Pos Z of your UI element might be off and something transparent might be over your slider.
Also, I would suggest, if you have overlapping menus option (like the option menu coming over a main menu) to switch the "interactable" value of all UI elements with such thing depending on the focused menu. (It requires some works, but it's working really well once well implemented.)
I set Raycast Target of the fader image off, and even deleted the fader canvas, set sorting order of the slider's canvas to 100, and set the slider's canvas layer to UI and all other element layers to below that, and it still doesn't work. "Interactable" is ticked and the slider appears interactable but clicks have no effect. It's even weirder because it is a prefab of a slider menu that works perfectly in another scene.