unity学习unity

Unity3D实现圆环进度条

2016-08-11  本文已影响590人  RY_zheng

最近在学Unity3D,看到一个博主做了一个圆环, 博客链接如下:
http://blog.csdn.net/tab_space/article/details/51775163
自动动手修改了点代码,并多画了两个进度条,比较拙劣,先分享在这里。

主要思路

  1. 用一个UI对象Image,导入图片资源,然后设置以下属性.在脚本中,每帧刷新改变Fill Amont属性的值,可以看到进度条变化.
{ 
"ImageType" : "Filled", 
"FillMethod" : "Radial 360",
"FillOrigin" : "Top",
"Clockwise" : False
}
Paste_Image.png
    void Update () {
        
        if (currentAmout < targetProcess) {
            Debug.Log("currentAmount:" + currentAmout.ToString());
            // 改变Fill Amont属性的值
            currentAmout += speed;
            if(currentAmout > targetProcess)
                currentAmout = targetProcess;
            indicator.GetComponent<Text>().text = ((int)currentAmout).ToString() + "%";
            process.GetComponent<Image>().fillAmount = currentAmout/100.0f;
        }
        
    }

效果

Paste_Image.png

Demo,包含Sketch的图片资源

上一篇下一篇

猜你喜欢

热点阅读