yyl
2025-06-04 a7f4c5ecc5268c49f6a6caf769b3ebee6f237662
Main/System/Launch/LoadingWin.cs
File was renamed from Main/UI/LoadingWin.cs
@@ -1,73 +1,73 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LoadingWin : UIBase
{
    protected int currentProgress = 0;
    protected int targetProgress = 0;
    protected Text titleText;
    protected Text tipsText;
    protected Image progressBar;
    protected Text progressText;
    protected override void InitComponent()
    {
        base.InitComponent();
        titleText = transform.Find("Text_Loading").GetComponent<Text>();
        tipsText = transform.Find("Text_Tips").GetComponent<Text>();
        progressBar = transform.Find("Img_Progress/Img_Foreground").GetComponent<Image>();
        progressText = transform.Find("Text_Progress").GetComponent<Text>();
    }
    protected override void OnPreOpen()
    {
        base.OnPreOpen();
        currentProgress = targetProgress = 0;
        Refresh();
    }
    protected override void OnPreClose()
    {
        base.OnPreClose();
    }
    public override void Refresh()
    {
        base.Refresh();
        UpdateProgress();
    }
    public void SetProgress(float value, bool directly = false)
    {
        if (directly)
        {
            currentProgress = targetProgress = (int)(value * 100);
            UpdateProgress();
        }
        else
        {
            currentProgress = (int)(value * 100);
        }
    }
    protected void UpdateProgress()
    {
        progressText.text = currentProgress + "%";
        progressBar.fillAmount = currentProgress / 100f;
    }
    protected void Update()
    {
        if (currentProgress < targetProgress)
        {
            currentProgress = (int)Mathf.Lerp(currentProgress, targetProgress, 0.1f);
            UpdateProgress();
        }
    }
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LoadingWin : UIBase
{
    protected int currentProgress = 0;
    protected int targetProgress = 0;
    protected Text titleText;
    protected Text tipsText;
    protected Image progressBar;
    protected Text progressText;
    protected override void InitComponent()
    {
        base.InitComponent();
        titleText = transform.Find("Text_Loading").GetComponent<Text>();
        tipsText = transform.Find("Text_Tips").GetComponent<Text>();
        progressBar = transform.Find("Img_Progress/Img_Foreground").GetComponent<Image>();
        progressText = transform.Find("Text_Progress").GetComponent<Text>();
    }
    protected override void OnPreOpen()
    {
        base.OnPreOpen();
        currentProgress = targetProgress = 0;
        Refresh();
    }
    protected override void OnPreClose()
    {
        base.OnPreClose();
    }
    public override void Refresh()
    {
        base.Refresh();
        UpdateProgress();
    }
    public void SetProgress(float value, bool directly = false)
    {
        if (directly)
        {
            currentProgress = targetProgress = (int)(value * 100);
            UpdateProgress();
        }
        else
        {
            currentProgress = (int)(value * 100);
        }
    }
    protected void UpdateProgress()
    {
        progressText.text = currentProgress + "%";
        progressBar.fillAmount = currentProgress / 100f;
    }
    protected void Update()
    {
        if (currentProgress < targetProgress)
        {
            currentProgress = (int)Mathf.Lerp(currentProgress, targetProgress, 0.1f);
            UpdateProgress();
        }
    }
}