| File was renamed from Main/UI/LoadingWin.cs |
| | |
| | | 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(); |
| | | } |
| | | } |
| | | } |