- Home /
I can't assign new UI sliders to variable slots in 4.6.2f1
I need to assign 2 sliders to variable slots to control them by script. I want to get the current volume of sound and music and set the position of the slider accordingly. I have done this successfully before.
The problem is that when I drag and drop the sliders to the variable slots (that are exposed in the component script ) they don't assign.
I have made a new scene in the same project and the assignment still doesn't work.
I have made a new project and everything works as it should. I can drag and drop to assign in a clean project.
Other UI and components assign/work fine. It's just the sliders and just in this project, regardless of the script that they are in.
Previous sliders are still assigned, But no sliders are showing up in the browser that appears when you click on the dotInsideCircle to the right of "None (Slider)".
I wonder if you should make a public GameObject variable, and drag and drop the Slider Object onto it. Then, take the slider "component" of it. Can't remember, it's been awhile since I was on Unity. Just a thought since no one has helped you yet.
Thank you for the suggestion, I will give that a try. I was considering GameObject.Find, but this is a better solution.
_musicVolumeSlider = _musicVolumeSliderGO.GetComponent< Slider >();
isn't working either. Unity considers this project devoid of sliders.
Also updating to 4.6.4f1 didn't solve problem.
Answer by dantheman272 · Aug 24, 2016 at 10:07 AM
I was having this problem in Unity 5.4.0f3, and in case anyone is looking for a solution and comes across this (or if you are still having this problem) I had to rename one of my scripts. If you have a "Slider" script, Unity will use that instead of the UnityEngine.UI. My Slider script happened to contain definitions for many of the same things as the UnityEngine.UI (for sliders at least) so it took me quite a while to figure it out. Anyway, best of luck, hope you have solved this before now.
Thanks for the reply, it's been so long I can't remember what I did, or what I was working on! So I won't be able to pick the correct answer between you and Zen_Hap, giving you both a bit of Rep ins$$anonymous$$d.
Answer by Zen_Hap · Aug 24, 2016 at 10:54 AM
Select the slider and scroll down to the Events section, ten drag the music object in and select Audio.Volume. Done!
Also, I just finished updating my game, (also made in Unity!) Buzzle! It is an Endless Bouncer/Runner arcade style game and I hope you like it! Be sure to download and play it for free! Link: www.gamejolt.com/games/buzzle/138631
Thanks for the reply, it's been so long I can't remember what I did, or what I was working on! I will check out your game.
Your answer
Follow this Question
Related Questions
2D slider (UI 4.6) for color picker (world space) 0 Answers
Create a slider which refers to a value in another script 2 Answers
HIdden cursor slider issue 1 Answer
Updating UI Slider through another script 1 Answer
4.6 UI Player Movement with Slider. 0 Answers