-
-
Save unitycoder/54a045fb0a696e73fe0d1222fd9eed95 to your computer and use it in GitHub Desktop.
TogglePassthrough.cs - For AR Foundation With Meta OpenXR Support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using UnityEngine.InputSystem; | |
| using UnityEngine.XR.ARFoundation; | |
| public class TogglePassthrough : MonoBehaviour | |
| { | |
| [SerializeField] | |
| private InputActionProperty toggleAction; | |
| private ARCameraManager arCameraManager; | |
| private void Awake() | |
| { | |
| toggleAction.action.Enable(); | |
| arCameraManager = FindAnyObjectByType<ARCameraManager>(); | |
| } | |
| private void OnTogglePerformed(InputAction.CallbackContext obj) | |
| { | |
| if(arCameraManager) | |
| arCameraManager.enabled = !arCameraManager.enabled; | |
| } | |
| private void OnEnable() => toggleAction.action.performed += OnTogglePerformed; | |
| private void OnDisable() => toggleAction.action.performed -= OnTogglePerformed; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment