void OnPointerActivated(object sender, ControllerInteractionEventArgs e)
{
// Start tracking touches
UICamera.GetInputTouchCount = OnGetTouchCount;
UICamera.GetInputTouch = OnGetTouch;
mTouches
.Add(new UICamera
.Touch() {
phase = TouchPhase.Began,
fingerId = 0,
position = HoverPosition,
tapCount = 1
});
}
void OnPointerHover(object sender, DestinationMarkerEventArgs e)
{
for (int index = 0; index < mTouches.size; ++index)
{
UICamera.Touch t = mTouches[index];
if (t.fingerId == 0)
{
var pointInScreenSpace = VRTK_DeviceFinder.HeadsetCamera().GetComponent<Camera>().WorldToScreenPoint(e.destinationPosition);
t
.position = new Vector2
(pointInScreenSpace
.x, pointInScreenSpace
.y); t.phase = TouchPhase.Moved;
HoverPosition = t.position;
break;
}
}
}
void OnPointerClicked()
{
for (int index = 0; index < mTouches.size; ++index)
{
UICamera.Touch t = mTouches[index];
if (t.fingerId == 0)
{
t.phase = TouchPhase.Ended;
t.position = HoverPosition;
break;
}
}
}
void OnPointerDeactivated(object sender, ControllerInteractionEventArgs e)
{
// Stop tracking touches
mTouches.Clear();
UICamera.GetInputTouchCount = null;
UICamera.GetInputTouch = null;
}
int OnGetTouchCount()
{
return mTouches.size;
}
UICamera.Touch OnGetTouch(int index)
{
return mTouches[index];
}
void LateUpdate()
{
int index = 0;
while (index < mTouches.size)
{
UICamera.Touch touch = mTouches[index];
if (touch.phase == TouchPhase.Ended)
{
mTouches.RemoveAt(index);
}
else
{
touch.phase = TouchPhase.Moved;
++index;
}
}
}