Unity3D实现圆环进度条

最近在学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的图片资源

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容