using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.EventSystems;
using System.Collections.Generic;
public class ButtonHold : MonoBehaviour,IPointerEnterHandler,IPointerExitHandler{
public Image image;
bool isHold = false;
float timer = 0;
void Start()
{
isHold = false;
timer = 0;
image.fillAmount = 0;
}
void Update()
{
if(isHold==true)
{
timer += Time.deltaTime;
timer = timer >= 5 ? 5 : timer;
if(timer>=5)
{
timer = 5;
Debug.Log("55555555555");
isHold = false; //补丁
}
image.fillAmount = timer / 5;
}
else
{
timer = 0;
}
}
public void OnPointerEnter(PointerEventData eventData)
{
isHold = true;
timer = 0;
}
public void OnPointerExit(PointerEventData eventData)
{
isHold = false;
timer = 0;
image.fillAmount = 0;
}
}
UGUI凝视Button功能
最新推荐文章于 2021-09-24 15:27:59 发布