public static void Deregister(NVRInteractable interactable) { NVRPlayer.DeregisterInteractable(interactable); ColliderMapping = ColliderMapping.Where(mapping => mapping.Value != interactable).ToDictionary(mapping => mapping.Key, mapping => mapping.Value); NVRInteractableMapping.Remove(interactable); }
public static void DeregisterInteractable(NVRInteractable interactable) { for (int index = 0; index < Instance.Hands.Length; index++) { Instance.Hands[index].DeregisterInteractable(interactable); } }
public static void Register(NVRInteractable interactable, Collider[] colliders) { NVRInteractableMapping.Add(interactable, colliders); for (int index = 0; index < colliders.Length; index++) { ColliderMapping.Add(colliders[index], interactable); } }
protected bool PickupClosest() { NVRInteractable closest = null; float closestDistance = float.MaxValue; foreach (var collider in GhostColliders) { foreach (var hovering in CurrentlyHoveringOver) { if (hovering.Key == null) { continue; } if (!hovering.Key.gameObject.activeInHierarchy) { continue; } var itemColliders = hovering.Value; itemColliders.Where(item => !item.Key.gameObject.activeInHierarchy).ToList().ForEach(item => itemColliders.Remove(item.Key)); float distance = Vector3.Distance(collider.transform.position, hovering.Key.transform.position); if (distance < closestDistance) { closestDistance = distance; closest = hovering.Key; } } } if (closest != null) { BeginInteraction(closest); return(true); } else { return(false); } }
protected virtual void OnTriggerStay(Collider collider) { NVRInteractable interactable = NVRInteractables.GetInteractable(collider); if (interactable == null || interactable.enabled == false) { return; } if (CurrentlyHoveringOver.ContainsKey(interactable) == false) { CurrentlyHoveringOver[interactable] = new Dictionary <Collider, float>(); } if (CurrentlyHoveringOver[interactable].ContainsKey(collider) == false) { CurrentlyHoveringOver[interactable][collider] = Time.time; } }
public static void Register(NVRInteractable interactable, Collider[] colliders) { if (Initialized == false) { Debug.LogError("[NewtonVR] Error: NVRInteractables.Register called before initialization."); } NVRInteractableMapping[interactable] = colliders; for (int index = 0; index < colliders.Length; index++) { ColliderMapping[colliders[index]] = interactable; } if (NVRInteractableList.Contains(interactable) == false) { NVRInteractableList.Add(interactable); } }
public virtual void BeginInteraction(NVRInteractable interactable) { if (interactable.CanAttach == true) { // Implemented hand controller should subscribe to this event and implement appropriate functionality OnBeginInteractionCustomHands.Invoke(interactable); CurrentlyInteracting = interactable; CurrentlyInteracting.BeginInteraction(this); if (PhysicalController) { PhysicalController.On(); // enable animation with Phyiscal Hand component during interaction } if (OnBeginInteraction != null) { OnBeginInteraction.Invoke(interactable); } } }
private void OnTriggerExit(Collider collider) { NVRInteractable interactable = NVRInteractables.GetInteractable(collider); if (interactable == null) { return; } if (CurrentlyHoveringOver.ContainsKey(interactable) == true) { if (CurrentlyHoveringOver[interactable].ContainsKey(collider) == true) { CurrentlyHoveringOver[interactable].Remove(collider); if (CurrentlyHoveringOver[interactable].Count == 0) { CurrentlyHoveringOver.Remove(interactable); } } } }
protected virtual void OnTriggerExit(Collider collider) { NVRInteractable interactable = NVRInteractables.GetInteractable(collider); if (interactable == null || collider.tag.Equals("Ungrabbable")) { return; } if (CurrentlyHoveringOver.ContainsKey(interactable)) { if (CurrentlyHoveringOver[interactable].ContainsKey(collider)) { CurrentlyHoveringOver[interactable].Remove(collider); if (CurrentlyHoveringOver[interactable].Count == 0) { CurrentlyHoveringOver.Remove(interactable); } } } }
public virtual void BeginInteraction(NVRInteractable interactable) { if (interactable.CanAttach == true) { if (interactable.AttachedHand != null) { if (interactable.AllowTwoHanded == false) { interactable.AttachedHand.EndInteraction(null); } } CurrentlyInteracting = interactable; CurrentlyInteracting.BeginInteraction(this); if (OnBeginInteraction != null) { OnBeginInteraction.Invoke(interactable); } } }
public virtual void EndInteraction(NVRInteractable item) { if (item != null && CurrentlyHoveringOver.ContainsKey(item) == true) { CurrentlyHoveringOver.Remove(item); } if (CurrentlyInteracting != null) { CurrentlyInteracting.EndInteraction(); CurrentlyInteracting = null; } if (CurrentInteractionStyle == InterationStyle.Toggle) { if (CurrentHandState != HandState.Idle) { CurrentHandState = HandState.Idle; } } }
public virtual void EndInteraction(NVRInteractable item) { if (item != null && CurrentlyHoveringOver.ContainsKey(item) == true) { CurrentlyHoveringOver.Remove(item); } if (CurrentlyInteracting != null) { // TODO: A more general event may be better ScenarioLogManager.Instance.LogEvent(this.gameObject, "OnRelease", CurrentlyInteracting.gameObject.name); CurrentlyInteracting.EndInteraction(); CurrentlyInteracting = null; } if (CurrentInteractionStyle == InteractionStyle.GripToggleToInteract) { if (CurrentHandState != HandState.Idle) { CurrentHandState = HandState.Idle; } } }
public virtual void EndInteraction(NVRInteractable item) { if (item != null && CurrentlyHoveringOver.ContainsKey(item) == true) CurrentlyHoveringOver.Remove(item); if (CurrentlyInteracting != null) { CurrentlyInteracting.EndInteraction(); CurrentlyInteracting = null; } if (CurrentInteractionStyle == InterationStyle.GripToggleToInteract) { if (CurrentHandState != HandState.Idle) { CurrentHandState = HandState.Idle; } } }
void SendBeginInteraction(NVRInteractable item) { NetworkObjectManager.Instance.SendBeginInterraction(item, this); }
public void DeregisterInteractable(NVRInteractable interactable) { if (CurrentlyInteracting == interactable) CurrentlyInteracting = null; CurrentlyHoveringOver.Remove(interactable); }
public void EndInteraction(NVRInteractable item) { if (item != null && CurrentlyHoveringOver.ContainsKey(item) == true) CurrentlyHoveringOver.Remove(item); if (CurrentlyInteracting != null) { CurrentlyInteracting.EndInteraction(); CurrentlyInteracting = null; } }
private void BeginInteraction(NVRInteractable interactable) { if (interactable.CanAttach == true) { if (interactable.AttachedHand != null) { interactable.AttachedHand.EndInteraction(null); } CurrentlyInteracting = interactable; CurrentlyInteracting.BeginInteraction(this); } }
void SendEndInteraction(NVRInteractable item) { NetworkObjectManager.Instance.SendEndInterraction(item); }