// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Input
{
///
/// This component handles pointer clicks from all types of input sources.
/// i.e. a primary mouse button click, motion controller selection press, or hand tap.
///
[System.Obsolete("Use PointerHandler instead of PointerClickHandler", true)]
[AddComponentMenu("Scripts/MRTK/Obsolete/PointerClickHandler")]
public class PointerClickHandler : BaseInputHandler, IMixedRealityPointerHandler
{
[SerializeField]
[Tooltip("The input actions to be recognized on pointer up.")]
private InputActionEventPair onPointerUpActionEvent = default(InputActionEventPair);
[SerializeField]
[Tooltip("The input actions to be recognized on pointer down.")]
private InputActionEventPair onPointerDownActionEvent = default(InputActionEventPair);
[SerializeField]
[Tooltip("The input actions to be recognized on pointer clicked.")]
private InputActionEventPair onPointerClickedActionEvent = default(InputActionEventPair);
private void Awake()
{
Debug.LogError("PointerClickHandler is deprecated. Use PointerHandler instead", this.gameObject);
}
#region InputSystemGlobalHandlerListener Implementation
///
protected override void RegisterHandlers()
{
CoreServices.InputSystem?.RegisterHandler(this);
}
///
protected override void UnregisterHandlers()
{
CoreServices.InputSystem?.UnregisterHandler(this);
}
#endregion InputSystemGlobalHandlerListener Implementation
#region IMixedRealityPointerHandler Implementation
///
public void OnPointerUp(MixedRealityPointerEventData eventData)
{
if (onPointerUpActionEvent.InputAction == MixedRealityInputAction.None) { return; }
if (onPointerUpActionEvent.InputAction == eventData.MixedRealityInputAction)
{
onPointerUpActionEvent.UnityEvent.Invoke();
}
}
///
public void OnPointerDown(MixedRealityPointerEventData eventData)
{
if (onPointerDownActionEvent.InputAction == MixedRealityInputAction.None) { return; }
if (onPointerDownActionEvent.InputAction == eventData.MixedRealityInputAction)
{
onPointerDownActionEvent.UnityEvent.Invoke();
}
}
///
public void OnPointerDragged(MixedRealityPointerEventData eventData) { }
///
public void OnPointerClicked(MixedRealityPointerEventData eventData)
{
if (onPointerClickedActionEvent.InputAction == MixedRealityInputAction.None) { return; }
if (onPointerClickedActionEvent.InputAction == eventData.MixedRealityInputAction)
{
onPointerClickedActionEvent.UnityEvent.Invoke();
}
}
#endregion IMixedRealityPointerHandler Implementation
}
}