89 lines
1.9 KiB
C#
89 lines
1.9 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using static UnityEngine.Rendering.DebugUI;
|
|
|
|
public class ProcessTipPanel : MonoBehaviour
|
|
{
|
|
public Image image;
|
|
public TextMeshProUGUI textMeshProUGUI;
|
|
/// <summary>
|
|
/// 是否启用进度
|
|
/// </summary>
|
|
private bool isCheck=false;
|
|
/// <summary>
|
|
/// 当前进入
|
|
/// </summary>
|
|
private float currentProcess=0;
|
|
/// <summary>
|
|
/// 是否结束
|
|
/// </summary>
|
|
private bool isOver=false;
|
|
|
|
/// <summary>
|
|
/// 结果回调
|
|
/// </summary>
|
|
private Action<bool> tmpback;
|
|
|
|
/// <summary>
|
|
/// 开始走进度
|
|
/// </summary>
|
|
/// <param name="back"></param>
|
|
public void StartProcess(Action<bool> back)
|
|
{
|
|
this.isCheck=true;
|
|
tmpback = back;
|
|
Debug.Log("开始核对和抄录");
|
|
textMeshProUGUI.text = "核对中";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 中止走进度
|
|
/// </summary>
|
|
public void StopProcess()
|
|
{
|
|
this.isCheck = false;
|
|
currentProcess = 0;
|
|
image.fillAmount = currentProcess;
|
|
tmpback(false);
|
|
}
|
|
|
|
|
|
void Update()
|
|
{
|
|
if (!isOver)
|
|
{
|
|
if (isCheck)
|
|
{
|
|
currentProcess = Mathf.Clamp01(currentProcess + Time.deltaTime * 0.3f);
|
|
image.fillAmount = currentProcess;
|
|
if (currentProcess == 1)
|
|
{
|
|
isOver = true;
|
|
ThisDestroy();
|
|
}
|
|
}
|
|
|
|
if (Input.GetMouseButtonUp(0))
|
|
{
|
|
StopProcess();
|
|
isOver = true;
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 核对记录成功
|
|
/// </summary>
|
|
private void ThisDestroy()
|
|
{
|
|
Debug.Log("核对和抄录完成!");
|
|
textMeshProUGUI.text = "核对完成";
|
|
tmpback(true);
|
|
Destroy(gameObject);
|
|
}
|
|
} |