UGUI系列-文字实现进度等待、进度加载、进程等待演示动画

2022-08-07 09:24:09 浏览数 (1)

一、前言

今天分享一下UGUI 文字实现进度等待、进度加载、进程等待演示动画,实现思路比较简单,效果也比较简单,仅供大家参考,谢谢

效果演示:

二、资源

源代码:https://download.csdn.net/download/q764424567/11644430

三、正文

编写脚本TextLoading.cs

代码语言:javascript复制
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TextLoading : MonoBehaviour
{
    public Text m_Text;
    float m_CurProgressValue2 = 0;
    float m_ProgressValue2 = 100;
    float m_CurProgressValueTemp = 0;

    void Update()
    {
        if (m_CurProgressValue2 < m_ProgressValue2)
        {
            m_CurProgressValue2  ;
        }
        if (m_CurProgressValue2 == 100)
        {
            m_CurProgressValue2 = 0;
        }
        m_CurProgressValueTemp = m_CurProgressValue2 / 100f;
        if (m_CurProgressValueTemp > 0.1f &amp;&amp; m_CurProgressValueTemp <= 0.3f)
        {
            m_Text.text = "○○○○●";
        }
        else if (m_CurProgressValueTemp > 0.3f &amp;&amp; m_CurProgressValueTemp <= 0.5f)
        {
            m_Text.text = "●○○○○";
        }
        else if (m_CurProgressValueTemp > 0.5f &amp;&amp; m_CurProgressValueTemp <= 0.7f)
        {
            m_Text.text = "○●○○○";
        }
        else if (m_CurProgressValueTemp > 0.7f &amp;&amp; m_CurProgressValueTemp <= 0.9f)
        {
            m_Text.text = "○○●○○";
        }
        else
        {
            m_Text.text = "○○○●○";
        }
    }
}

代码比较简单,就不做注释了

0 人点赞