OVRMonoscopic.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /************************************************************************************
  2. Copyright : Copyright 2017 Oculus VR, LLC. All Rights reserved.
  3. Licensed under the Oculus VR Rift SDK License Version 3.4.1 (the "License");
  4. you may not use the Oculus VR Rift SDK except in compliance with the License,
  5. which is provided at the time of installation or download, or which
  6. otherwise accompanies this software in either electronic or hard copy form.
  7. You may obtain a copy of the License at
  8. https://developer.oculus.com/licenses/sdk-3.4.1
  9. Unless required by applicable law or agreed to in writing, the Oculus VR SDK
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ************************************************************************************/
  15. using UnityEngine;
  16. /// <summary>
  17. /// Allows you to toggle monoscopic rendering with a gamepad button press.
  18. /// </summary>
  19. public class OVRMonoscopic : MonoBehaviour
  20. {
  21. /// <summary>
  22. /// The gamepad button that will toggle monoscopic rendering.
  23. /// </summary>
  24. public OVRInput.RawButton toggleButton = OVRInput.RawButton.B;
  25. private bool monoscopic = false;
  26. /// <summary>
  27. /// Check input and toggle monoscopic rendering mode if necessary
  28. /// See the input mapping setup in the Unity Integration guide
  29. /// </summary>
  30. void Update()
  31. {
  32. // NOTE: some of the buttons defined in OVRInput.RawButton are not available on the Android game pad controller
  33. if (OVRInput.GetDown(toggleButton))
  34. {
  35. //*************************
  36. // toggle monoscopic rendering mode
  37. //*************************
  38. monoscopic = !monoscopic;
  39. OVRManager.instance.monoscopic = monoscopic;
  40. }
  41. }
  42. }