/****************************************************************************
* Copyright 2019 Nreal Techonology Limited. All rights reserved.
*
* This file is part of NRSDK.
*
* https://www.nreal.ai/
*
*****************************************************************************/
namespace NRKernal
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
/// A nr pointer event data.
public class NRPointerEventData : PointerEventData
{
/// The raycaster.
public readonly NRPointerRaycaster raycaster;
/// The position 3D.
public Vector3 position3D;
/// The rotation.
public Quaternion rotation;
/// The position 3D delta.
public Vector3 position3DDelta;
/// The rotation delta.
public Quaternion rotationDelta;
/// The press position 3D.
public Vector3 pressPosition3D;
/// The press rotation.
public Quaternion pressRotation;
/// The press distance.
public float pressDistance;
/// The press enter.
public GameObject pressEnter;
/// True if press precessed.
public bool pressPrecessed;
/// Constructor.
/// The raycaster.
/// The event system.
public NRPointerEventData(NRPointerRaycaster raycaster, EventSystem eventSystem) : base(eventSystem)
{
this.raycaster = raycaster;
}
/// Gets the press.
/// True if it succeeds, false if it fails.
public virtual bool GetPress()
{
if (raycaster is NRMultScrPointerRaycaster)
{
return NRVirtualDisplayer.SystemButtonState.pressing;
}
else
{
return NRInput.GetButton(raycaster.RelatedHand, ControllerButton.TRIGGER);
}
}
/// Gets press down.
/// True if it succeeds, false if it fails.
public virtual bool GetPressDown()
{
if (raycaster is NRMultScrPointerRaycaster)
{
return NRVirtualDisplayer.SystemButtonState.pressDown;
}
else
{
return NRInput.GetButtonDown(raycaster.RelatedHand, ControllerButton.TRIGGER);
}
}
/// Gets press up.
/// True if it succeeds, false if it fails.
public virtual bool GetPressUp()
{
if (raycaster is NRMultScrPointerRaycaster)
{
return NRVirtualDisplayer.SystemButtonState.pressUp;
}
else
{
return NRInput.GetButtonUp(raycaster.RelatedHand, ControllerButton.TRIGGER);
}
}
}
}