10183人加入学习
(109人评价)
UGUI整体解决方案-基础篇(Unity 2019.1.0f2)

2019-06-01

价格 免费

加载进度条的实时

Slider slider = GetComponment<Slideer>();

fload process  = 0 ;

while(process  < 1){

}

[展开全文]

当前值 = Mathf.SmoothStep(当前值,目标值,时间)

 

类似LERP,平滑赋值

 

waitUntil(函数体),当函数体执行完毕,跳出循环。

[展开全文]
public class SliderTest : MonoBehaviour {

	// Use this for initialization
	void Start () {
        StartCoroutine(ChangeValue());
	}
    private IEnumerator ChangeValue()
    {
        Slider slider = GetComponent<Slider>();
        float process = 0;
        while (process < 1) {
            process += 0.1f;
            yield return new WaitUntil(() =>
                {
                    slider.value = Mathf.SmoothStep(slider.value, process, 0.5f);
                    return process - slider.value <= 0.01f;
                });
        }
    }
}

使Slider实现进度条的功能。

因为进度条进行的不光滑,所以还需要改进。

public class SliderTest : MonoBehaviour {

	// Use this for initialization
	void Start () {
        StartCoroutine(ChangeValue());
	}
    private IEnumerator ChangeValue()
    {
        Slider slider = GetComponent<Slider>();
        float process = 0;
        while (process < 1) {
            process += 0.1f;
            yield return new WaitUntil(() =>
                {
                    slider.value = Mathf.SmoothStep(slider.value, process, 0.5f);
                    return process - slider.value <= 0.01f;
                });
        }
    }
}

 

[展开全文]

授课教师

课程特色

视频(61)
下载资料(1)