XRSettingsWrapper.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * Copyright (c) 2021 Vuplex Inc. All rights reserved.
  3. *
  4. * Licensed under the Vuplex Commercial Software Library License, you may
  5. * not use this file except in compliance with the License. You may obtain
  6. * a copy of the License at
  7. *
  8. * https://vuplex.com/commercial-library-license
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. using UnityEngine;
  17. #if UNITY_2017_2_OR_NEWER
  18. using UnityEngine.XR;
  19. #else
  20. using XRSettings = UnityEngine.VR.VRSettings;
  21. #endif
  22. namespace Vuplex.WebView {
  23. /// <summary>
  24. /// Utility class to help manage the name change from VRSettings
  25. /// to XRSettings that occurred in Unity 2017.2.
  26. /// </summary>
  27. public class XRSettingsWrapper {
  28. public static XRSettingsWrapper Instance {
  29. get {
  30. if (_instance == null) {
  31. _instance = new XRSettingsWrapper();
  32. }
  33. return _instance;
  34. }
  35. }
  36. public bool enabled {
  37. get {
  38. return XRSettings.enabled;
  39. }
  40. }
  41. public RenderTextureDescriptor eyeTextureDesc {
  42. get {
  43. return XRSettings.eyeTextureDesc;
  44. }
  45. }
  46. public string loadedDeviceName {
  47. get {
  48. return XRSettings.loadedDeviceName;
  49. }
  50. }
  51. public string[] supportedDevices {
  52. get {
  53. return XRSettings.supportedDevices;
  54. }
  55. }
  56. static XRSettingsWrapper _instance;
  57. }
  58. }