private void onPressed(HandsInteractionManager.HandPointClass hand) { HandObjectClass obj; if (HandObjects.TryGetValue(hand.id, out obj)) { if (HandObjects.Count > 1) { obj.onPressed(true); } else { obj.onPressed(false); } } int count = 0; foreach (var item in HandObjects.Values) { if (item.GetPress()) { count++; } } if (count == 2) { multipressflag = true; multipresstime = Time.time; } }
private void onLost(HandsInteractionManager.HandPointClass hand) { HandObjectClass obj; if (HandObjects.TryGetValue(hand.id, out obj)) { obj.DestroyObject(); HandObjects.Remove(hand.id); } }
private void onReleased(HandsInteractionManager.HandPointClass hand) { HandObjectClass obj; if (HandObjects.TryGetValue(hand.id, out obj)) { HandGestureState state = obj.onReleased(); if (HandObjects.Count == 1) { if (state == HandGestureState.Tap) { if (HandGestureEvent != null) { HandGestureEvent(state); } } else if (state == HandGestureState.DoubleTap) { if (HandGestureEvent != null) { HandGestureEvent(state); } } } else { foreach (var item in HandObjects.Values) { if (item.GetPress()) { return; } } if (multipressflag) { if (Time.time - multipresstime < PressIntervalTime) { if (Time.time - multitaptime < PressIntervalTime) { if (HandGestureEvent != null) { HandGestureEvent(HandGestureState.MultiDoubleTap); } } else { if (HandGestureEvent != null) { HandGestureEvent(HandGestureState.MultiTap); } } } multipressflag = false; multitaptime = Time.time; } else { if (state == HandGestureState.Tap) { if (HandGestureEvent != null) { HandGestureEvent(HandGestureState.ShiftTap); } } else if (state == HandGestureState.DoubleTap) { if (HandGestureEvent != null) { HandGestureEvent(HandGestureState.ShiftDoubleTap); } } } } } if (HandGestureEvent != null) { HandGestureEvent(HandGestureState.Release); } }
private void onUpdated(HandsInteractionManager.HandPointClass hand) { HandObjectClass obj; if (HandObjects.TryGetValue(hand.id, out obj)) { HandGestureState state = obj.onUpdated(hand.pos, Offset_up, Offset_foward); if (HandObjects.Count == 1) { if (state == HandGestureState.Hold) { if (HandGestureEvent != null) { HandGestureEvent(state); } } else if (state == HandGestureState.DragStart) { if (SingleHandGestureEvent != null) { SingleHandGestureEvent(state, obj.GetPosition()); } } else if (state == HandGestureState.Drag) { if (SingleHandGestureEvent != null) { SingleHandGestureEvent(state, obj.GetPosition()); } } } else { int dragcount = 0; Vector3[] pos = new Vector3[2]; foreach (var item in HandObjects.Values) { if (item.GetPress()) { pos[dragcount] = item.GetPosition(); dragcount++; } } if (dragcount == 2) { if (Time.time - multipresstime > PressIntervalTime) { if (multihandflag == false) { if (MultiHandGestureEvent != null) { MultiHandGestureEvent(HandGestureState.MultiDragStart, pos[0], pos[1]); } multihandflag = true; } else { if (MultiHandGestureEvent != null) { MultiHandGestureEvent(HandGestureState.MultiDrag, pos[0], pos[1]); } } } obj.SetHandObjectControlRelease(); } else { if (multihandflag) { if (dragcount == 0) { multihandflag = false; } } else { if (state == HandGestureState.Hold) { if (HandGestureEvent != null) { HandGestureEvent(HandGestureState.ShiftHold); } } else if (state == HandGestureState.DragStart) { if (SingleHandGestureEvent != null) { SingleHandGestureEvent(HandGestureState.ShiftDragStart, obj.GetPosition()); } } else if (state == HandGestureState.Drag) { if (SingleHandGestureEvent != null) { SingleHandGestureEvent(HandGestureState.ShiftDrag, obj.GetPosition()); } } } } } } }
private void onDetected(HandsInteractionManager.HandPointClass hand) { HandObjects.Add(hand.id, new HandObjectClass(HandObjectPrefab, transform, HoldTriggerTime, PressIntervalTime, DragDistance)); }
private void onReleased(HandsInteractionManager.HandPointClass hand) { HandObjectClass obj; if (HandObjects.TryGetValue(hand.id, out obj)) { HandObjectState state = obj.onReleased(); foreach (var item in HandObjects.Values) { if (item.GetPress()) { return; } } if (multipressflag) { if (Time.time - multipresstime < PressIntervalTime) { if (Time.time - multitaptime < PressIntervalTime) { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.MultiDoubleTap); } } else { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.MultiTap); } } } multipressflag = false; multitaptime = Time.time; } else { if (state == HandObjectState.Tap) { if (obj.GetShiftFlag() == false) { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.SelectTap); } } else { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.GripTap); } } } else if (state == HandObjectState.DoubleTap) { if (obj.GetShiftFlag() == false) { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.SelectDoubleTap); } } else { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.GripDoubleTap); } } } } } if (HandControllerEndEvent != null) { HandControllerEndEvent(); } }
private void onUpdated(HandsInteractionManager.HandPointClass hand) { HandObjectClass obj; if (HandObjects.TryGetValue(hand.id, out obj)) { HandObjectState state = obj.onUpdated(hand.pos, hand.rot, Offset_up, Offset_foward); int dragcount = 0; Vector3[] pos = new Vector3[2]; Quaternion[] rot = new Quaternion[2]; foreach (var item in HandObjects.Values) { if (item.GetPress()) { pos[dragcount] = item.GetPosition(); rot[dragcount] = item.GetRotation(); dragcount++; } } if (dragcount == 2) { if (Time.time - multipresstime > PressIntervalTime) { if (multihandflag == false) { if (HandControllerStartEvent != null) { HandControllerStartEvent(HandControllerState.MultiDrag, pos[0], rot[0], pos[1], rot[1]); } multihandflag = true; } else { if (HandControllerUpdateEvent != null) { HandControllerUpdateEvent(HandControllerState.MultiDrag, pos[0], rot[0], pos[1], rot[1]); } } } obj.SetHandObjectControlRelease(); } else { if (multihandflag) { if (dragcount == 0) { multihandflag = false; } } else { if (state == HandObjectState.Hold) { if (obj.GetShiftFlag() == false) { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.SelectHold); } } else { if (HandControllerEvent != null) { HandControllerEvent(HandControllerState.GripHold); } } } else if (state == HandObjectState.DragStart) { if (obj.GetShiftFlag() == false) { if (HandControllerStartEvent != null) { HandControllerStartEvent(HandControllerState.SelectDrag, obj.GetPosition(), obj.GetRotation(), null, null); } } else { if (HandControllerStartEvent != null) { HandControllerStartEvent(HandControllerState.GripDrag, obj.GetPosition(), obj.GetRotation(), null, null); } } } else if (state == HandObjectState.DragUpdate) { if (obj.GetShiftFlag() == false) { if (HandControllerUpdateEvent != null) { HandControllerUpdateEvent(HandControllerState.SelectDrag, obj.GetPosition(), obj.GetRotation(), null, null); } } else { if (HandControllerUpdateEvent != null) { HandControllerUpdateEvent(HandControllerState.GripDrag, obj.GetPosition(), obj.GetRotation(), null, null); } } } } } } }