using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using static UnityEngine.Rendering.DebugUI;
public class ProcessTipPanel : MonoBehaviour
{
public Image image;
///
/// 是否启用进度
///
private bool isCheck=false;
///
/// 当前进入
///
private float currentProcess=0;
///
/// 是否结束
///
private bool isOver=false;
///
/// 结果回调
///
private Action tmpback;
///
/// 开始走进度
///
///
public void StartProcess(Action back)
{
this.isCheck=true;
tmpback = back;
Debug.Log("开始核对和抄录");
}
///
/// 中止走进度
///
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;
Invoke("ThisDestroy", 2);
}
}
if (Input.GetMouseButtonUp(0))
{
StopProcess();
isOver = true;
Destroy(gameObject);
}
}
}
///
/// 核对记录成功
///
private void ThisDestroy()
{
Debug.Log("核对和抄录完成!");
tmpback(true);
Destroy(gameObject);
}
}