Unity3D 之UGUI 滑动条(Slider)

这里来讲解下UGUI 滑动条(Slider)的用法

控件下面有三个游戏对象

Background -->背景

Fill Area --> 前景区域

Handle Slide Area --> 滑动条

Slider的属性

其他几个设置和其他控件都差不多,这里来讲解几个特有的属性。

Direction -->方向

Whole Numbers -->控制整数输入

然后来看下脚本控制。这里的方法调用和其他的不用,方法里面有浮点参数

using UnityEngine;
using System.Collections;

public class SilderTest : MonoBehaviour {

    // Use this for initialization
    void Start () {
    
    }
    
    // Update is called once per frame
    void Update () {
    
    }
    public void SliderTest(float even) {
        Debug.LogError("您的血量=" +even );
    }
}

然后通过绑定脚本,能够在改变滑动条的值的时候,调用方法。

原文地址:https://www.cnblogs.com/sunxun/p/5517760.html