This repository has been archived on 2026-01-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Frontec/Assets/Scripts/UI/UI_EventHandler.cs
jmaniuvc 2936c48466 Frontec
2025-02-24 12:12:52 +09:00

39 lines
830 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class UI_EventHandler : MonoBehaviour, IPointerClickHandler, IPointerDownHandler, IPointerUpHandler
{
public Action OnClickHandler = null;
public Action OnPressedHandler = null;
public Action OnPointerDownHandler = null;
public Action OnPointerUpHandler = null;
bool _pressed = false;
private void Update()
{
if (_pressed)
OnPressedHandler?.Invoke();
}
public void OnPointerClick(PointerEventData eventData)
{
OnClickHandler?.Invoke();
}
public void OnPointerDown(PointerEventData eventData)
{
_pressed = true;
OnPointerDownHandler?.Invoke();
}
public void OnPointerUp(PointerEventData eventData)
{
_pressed = false;
OnPointerUpHandler?.Invoke();
}
}