41 lines
957 B
C#
41 lines
957 B
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class InputManager
|
|
{
|
|
public Action KeyAction = null;
|
|
public Action<Define.MouseEvent> MouseAction = null;
|
|
|
|
bool _pressed = false;
|
|
|
|
// ReSharper disable Unity.PerformanceAnalysis
|
|
public void OnUpdate()
|
|
{
|
|
// if(Input.anyKey == false) return;
|
|
if(EventSystem.current.IsPointerOverGameObject()) return;
|
|
|
|
if (Input.anyKey && KeyAction != null) KeyAction.Invoke();
|
|
|
|
if (MouseAction != null)
|
|
{
|
|
if (Input.GetMouseButton(0))
|
|
{
|
|
MouseAction.Invoke(Define.MouseEvent.Press);
|
|
_pressed = true;
|
|
}
|
|
else
|
|
{
|
|
if (_pressed) MouseAction.Invoke(Define.MouseEvent.Click);
|
|
_pressed = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
KeyAction = null;
|
|
MouseAction = null;
|
|
}
|
|
}
|