Module_Device.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. 
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. namespace SC.XR.Unity.Module_Device {
  7. public class Module_Device {
  8. private static Module_Device instance;
  9. public static Module_Device getInstance {
  10. get {
  11. if (instance == null) {
  12. instance = new Module_Device();
  13. }
  14. return instance;
  15. }
  16. }
  17. private DeviceList _deviceAssets;
  18. private DeviceList deviceAssets {
  19. get {
  20. if (_deviceAssets == null) {
  21. _deviceAssets = Resources.Load<DeviceList>("DeviceList");
  22. }
  23. return _deviceAssets;
  24. }
  25. }
  26. private DeviceBase _current;
  27. public DeviceBase Current {
  28. get {
  29. if (_current == null) {
  30. if (!Application.isEditor && Application.platform == RuntimePlatform.Android) {
  31. foreach (var item in deviceAssets.androidDevice) {
  32. if (item.modelName == item.MODEL) {
  33. _current = item;
  34. break;
  35. }
  36. }
  37. if (_current == null) {
  38. foreach (var item in deviceAssets.androidDevice) {
  39. if (item.type == AndroidDeviceType.Other ) {
  40. _current = item;
  41. break;
  42. }
  43. }
  44. }
  45. CurrentAndroid = (AndroidDevice)_current;
  46. } else if (Application.platform == RuntimePlatform.IPhonePlayer) {
  47. if (deviceAssets.iosDevice != null) {
  48. _current = deviceAssets.iosDevice;
  49. }
  50. } else {
  51. if (deviceAssets.standaloneDevice != null) {
  52. _current = deviceAssets.standaloneDevice;
  53. }
  54. }
  55. }
  56. return _current;
  57. }
  58. }
  59. public AndroidDevice CurrentAndroid { get; private set; }
  60. }
  61. }