728x90
반응형
1.
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class ButtonTimer : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
[SerializeField]
float SetTime;
float timeremain;
Button UIButton;
void Start()
{
UIButton = GetComponent<Button>();
timeremain = SetTime;
}
public void OnPointerEnter(PointerEventData eventData)
{
InvokeRepeating("countDown", 0, Time.deltaTime);
}
public void OnPointerExit(PointerEventData eventData)
{
CancelInvoke("countDown");
timeremain = SetTime;
}
void countDown()
{
if (timeremain < 0)
{
UIButton.onClick.Invoke();
CancelInvoke("countDown");
timeremain = SetTime;
}
timeremain-=Time.deltaTime;
}
public void GazeSelect()
{
Debug.Log(gameObject.name + "selected");
}
}
// 같이 프로젝트를 진행한 팀원이 작성한 것으로, 추가 공부 필수
728x90
'Unity > FAS project 코드 정리' 카테고리의 다른 글
InputDrone JSON (0) | 2021.06.12 |
---|---|
Drone 이동 스크립트 (0) | 2021.06.12 |
Button 클릭 시, Sound 효과 설정 (0) | 2020.12.13 |
Camera 인식 범위 조정 (0) | 2020.12.13 |
Skybox 회전하기 (0) | 2020.12.13 |