RaycastToggle.cs 864 B

12345678910111213141516171819202122232425262728
  1. // /******************************************************************************
  2. // * File: RaycastToggle.cs
  3. // * Copyright (c) 2023 Qualcomm Technologies, Inc. and/or its subsidiaries. All rights reserved.
  4. // *
  5. // *
  6. // ******************************************************************************/
  7. using UnityEngine;
  8. using UnityEngine.XR.Interaction.Toolkit;
  9. namespace QCHT.Samples.Proximal
  10. {
  11. public class RaycastToggle : MonoBehaviour
  12. {
  13. private XRRayInteractor[] rayInteractors;
  14. private void Awake() {
  15. rayInteractors = FindObjectsOfType<XRRayInteractor>(true);
  16. }
  17. public void ToggleRayInteractors(bool enable) {
  18. foreach (var rayInteractor in rayInteractors) {
  19. if (rayInteractor != null)
  20. rayInteractor.enabled = enable;
  21. }
  22. }
  23. }
  24. }