LGK Screen Input is a library for manage screen (touch) input for Unity Game Engine. You can take alook Unity-LGKScreenInput-Example for the example.
- Pointer Event : Pointer Down, Pointer Move and Pointer Up
- Pointer Action : Tap, Long Tap, Drag, Pinch Swipe
- Standalone and Mobile (standlone using mouse pointer and mobile using touch)
- Blocked by Unity UI
- Instansiate instance of
ScreenInputManager
ScreenInputManager manager = new ScreenInputManager ();
- Suscribe and unsuscribe input event in
MonoBehaviour.OnEnable()
andMonoBehaviour.OnDisable
private void OnEnable ()
{
manager.OnPointerDown += OnPointerDown_Handler;
manager.OnPointerMoved += OnPointerMoved_Handler;
manager.OnPointerUp += OnPointerUp_Handler;
manager.OnTap += OnTap_Handler;
manager.OnDoubleTap += OnDoubleTap_Handler;
manager.OnLongTap += OnLongTap_Handler;
manager.OnSwipe += OnSwipe_Handler;
manager.OnDrag += OnDrag_Handler;
manager.OnPinch += OnPinch_Handler;
}
private void OnDisable ()
{
manager.OnPointerDown -= OnPointerDown_Handler;
manager.OnPointerMoved -= OnPointerMoved_Handler;
manager.OnPointerUp -= OnPointerUp_Handler;
manager.OnTap -= OnTap_Handler;
manager.OnDoubleTap -= OnDoubleTap_Handler;
manager.OnLongTap -= OnLongTap_Handler;
manager.OnSwipe -= OnSwipe_Handler;
manager.OnDrag -= OnDrag_Handler;
manager.OnPinch -= OnPinch_Handler;
}
- Call
ScreenInputManager.Update(float)
on yourMonoBehavour.Update()
private void Update ()
{
manager.Update (Time.deltaTime);
}
public delegate void PointerEvent(IPointer pointer);
public delegate void TapEvent(Vector2 position,float totalTime);
public delegate void SwipeEvent(Vector2 direction,float totalTime);
public delegate void DragEvent(Vector2 position,Vector2 deltaPosition);
public delegate void PinchEvent(Vector2 position,float deltaScale);
- You can post issue for
Idea
, orBugs
- You can create merge request