public void TryGrab() { if (grabbingObject != null) { Debug.Log("Somehow grabbed something while already grabbing something else. Calling ReleaseGrab on that object."); ReleaseGrab(); } if (hoveringObject == null) { return; } IXRGrabbable newgrab = hoveringObject.GetTransform().GetComponent <IXRGrabbable>(); if (newgrab == null) { return; } if (!Equals(hoveringObject, null)) { hoveringObject.OnHoverEnd(); } hoveringObject = null; newgrab.OnGrabStart(transform); grabbingObject = newgrab; PlaySoundIfValid(grabStartSound); }
public void ReleaseGrab() { if (grabbingObject == null) { return; } grabbingObject.OnGrabEnd(); grabbingObject = null; PlaySoundIfValid(grabEndSound); }
private void OnDisable() { if (hoveringObject != null) { if (!Equals(hoveringObject, null)) { hoveringObject.OnHoverEnd(); } hoveringObject = null; } if (grabbingObject != null) { grabbingObject.OnGrabEnd(); grabbingObject = null; } collidingHoverables.Clear(); collidingGrabbables.Clear(); collidingClickables.Clear(); }
private void OnTriggerExit(Collider collision) { IXRHoverable newhoverable = collision.gameObject.GetComponent <IXRHoverable>(); if (newhoverable != null && collidingHoverables.Contains(newhoverable)) { collidingHoverables.Remove(newhoverable); } IXRClickable newclickable = collision.gameObject.GetComponent <IXRClickable>(); if (newclickable != null && collidingClickables.Contains(newclickable)) { collidingClickables.Remove(newclickable); } IXRGrabbable newgrabbable = collision.gameObject.GetComponent <IXRGrabbable>(); if (newgrabbable != null && collidingGrabbables.Contains(newgrabbable)) { collidingGrabbables.Remove(newgrabbable); } }