CameraToggleBeamVisibility.cs 759 B

123456789101112131415161718192021222324252627282930
  1. using UnityEngine;
  2. namespace VLB_Samples
  3. {
  4. [RequireComponent(typeof(Camera))]
  5. public class CameraToggleBeamVisibility : MonoBehaviour
  6. {
  7. [SerializeField] KeyCode m_KeyCode = KeyCode.Space;
  8. void Update()
  9. {
  10. if (Input.GetKeyDown(m_KeyCode))
  11. {
  12. var cam = GetComponent<Camera>();
  13. int layerID = VLB.Config.Instance.geometryLayerID;
  14. int layerMask = 1 << layerID;
  15. if ((cam.cullingMask & layerMask) == layerMask)
  16. {
  17. cam.cullingMask &= ~layerMask;
  18. }
  19. else
  20. {
  21. cam.cullingMask |= layerMask;
  22. }
  23. }
  24. }
  25. }
  26. }