protected virtual void SetColliderState(bool state, InteractableObjectEventArgs e) { if (addMenuCollider && menuCollider != null) { if (state) { menuCollider.enabled = true; menuCollider.center = desiredColliderCenter; } else { bool should = true; Collider[] colliders = eventsManager.GetComponents <Collider>(); Collider[] controllerColliders = e.interactingObject.GetComponent <VRTK_InteractTouch>().ControllerColliders(); for (int i = 0; i < colliders.Length; i++) { Collider collider = colliders[i]; if (collider != menuCollider) { for (int j = 0; j < controllerColliders.Length; j++) { Collider controllerCollider = controllerColliders[j]; if (controllerCollider.bounds.Intersects(collider.bounds)) { should = false; } } } } if (should) { menuCollider.center = new Vector3(100000000.0f, 100000000.0f, 100000000.0f); // This needs to be done to get OnTriggerExit() to fire, unfortunately waitingToDisableCollider = true; // Need to give other things time to realize that they're not colliding with this anymore, so do it a couple FixedUpdates } else { menuCollider.enabled = false; } } } }
private void SetColliderState(bool state, InteractableObjectEventArgs e) { if (addMenuCollider && menuCollider != null) { if (state) { menuCollider.enabled = true; menuCollider.center = desiredColliderCenter; } else { bool should = true; Collider[] colliders = eventsManager.GetComponents <Collider>(); SphereCollider controllerCollider = e.interactingObject.GetComponent <SphereCollider>(); foreach (Collider collider in colliders) { if (collider != menuCollider) { if (controllerCollider.bounds.Intersects(collider.bounds)) { should = false; } } } if (should) { menuCollider.center = new Vector3(100000000.0f, 100000000.0f, 100000000.0f); // This needs to be done to get OnTriggerExit() to fire, unfortunately waitingToDisableCollider = true; // Need to give other things time to realize that they're not colliding with this anymore, so do it a couple FixedUpdates } else { menuCollider.enabled = false; } } } }