Study notes, please correct me if you have any mistakes. The number is also please point out, thank you.
The slider is made up of 4 parts: Slider (Body), Background (background), fill (fill), and handle (slide handle)
Fill rect: Fills the area, fills the rect Transform, usually the image element
Handle rect: Drag handle, filled with rect Transform, typically an image element
Direction: direction, with LeftToRight (from left to right) RightToLeft (right to left), TopToBottom (top to bottom) and bottomtotop (bottom to top)
Min Value: Minimum
Max value: Max
Whole Numbers: Whether to limit to integers
Value: Current value
Volume text
Public Text volume;
Slide Bar
Public slider slider;
Default Volume
float startvolume = 0.5f;
void Start ()
{
Start by assigning the default volume to sliders and text
Volume.text = Startvolume.tostring ();
Slider.value = Startvolume;
}
public void Onpress_slider ()
{
When sliding the slider bar, assign the most recent value to volume and set the string to 2 decimal places
Volume.text = slider.value.ToString ("F2");
}
Slider Component Split (script):1:background Background 2:fill area fill (empty object) Fill (image) 3:handle Slide zone: Slider (empty object) handle (image) Fill rect: Fills the rectangular region (which is optional Fill others) Handle Rect: Handle rectangular Area direction: Handle direction
Min value: Min value max value: Maximum value whole Numbers: integer value: Tick on whole Numbers after value value is integer values: numeric value (minus handle becomes pure progress bar) event: On value Changed event. Public Text Text_displayvalue;
public void Display_slider (float flovalue)
{
Text_displayvalue.text = Flovalue.tostring ();
The script hangs empty to the image, more flexible navigation
Ten slider controls (slider bar)