UGUI 学习笔记8 Slider

Slider
1. 属性详解
Interactable : Will this component accept input? 是否可用
Transition : Properties that determine the way the control responds visually to user actions. 状态变化(参考Button 里的解释)

Naigation : Properties that determine the sequence of controls. 热键关联
Fill Rect : The graphic used for the fill area of the control. 填充区域(滑块左边的背景图)
Handle Rect : The graphic used for the sliding “handle” part of the control. 操作区域(滑块)
Direction : The direction in which the slider’s value will increase when the handle is dragged.The options are Left To Right,Right To Left,Bottom To Top and Top To Bottom. 滑动方向,Left To Right 从左往右 Right To Left 从右往左
Min Value : The value of the slider when the handle is at its extreme lower end (determined by the Direction property). 最小值
Max Value : The value of the slider when the handle is at its extreme upper end(determined by the Direction property). 最大值
Whole Numbers : Should the slider be constrained to integer values? 整数
Value : Current numeric value of the slider.If the value is set in the inspector it will be used as the initial value,but this will change at runtime when the value changes. 进度条的值
On Value Changed : A UnityEvent that is invoked when the current value of the Slider has changed.The event can send the current value as a float type dynamic argument.The value is passed as a float type regardless of whether the Whole Numbers property is enabled. 值改变事件
2. 控件组成详解
UGUI 学习笔记8 Slider
UGUI 学习笔记8 Slider
Background滑动条的背景,图中黄色的部分
Fill Area 填充区域,图中红色的部分
Handle Slide Area 滑块,图中蓝色部分
Background,Fill,Handle都是Image控件,可以任意更改设置。
UGUI 学习笔记8 Slider
Slider脚本中,Fill Rect添加Fill对象,Handle Rect 添加Handle对象。
3. 代码控制
UGUI 学习笔记8 Slider
Slider脚本中,On Value Changed添加函数,当滑动滑块是就会调用改函数。
UGUI 学习笔记8 Slider
通过滑动调让Image的颜色由黑变白。
UGUI 学习笔记8 Slider