C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Unity UI SliderThe Slider UI element is commonly used where a certain value should be set between a minimum and maximum value pair. One of the most common usages of this is for audio volume, screen brightness, or for doing zoom. To create a slider UI, right-click on the scene hierarchy and select GameObject -> UI -> Slider. A new slider element will display on your scene. Now, select the slider and go to the Inspector tab. Let's try to make a volume slider. For this open the ButtonAction script which we previously created and did some changes on it: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ButtonAction : MonoBehaviour { public Text myText; public Slider mySlider; void Update() { myText.text = "Current Volume: " + mySlider.value; } } Attach this script to the ButtonGameObject (which we previously created). Now, you will get a new slot for slider in the Inspector tab of ButtonGameObject. Drag the slider from the Hierarchy tab to the newly created slot (My Slider) of ButtonGameObject. Change the slider's maximum value to 100. And check mark for Whole Numbers. Here, I changed the color of Text to green from its properties, so that it will be more visible. Now press the play button and slide the slider.
Next TopicUnity UI Text
|