SDKGlobalConfigTranslation.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. using SC.XR.Unity;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. namespace SC.XR.Unity
  7. {
  8. public class SDKGlobalConfigTranslation : MonoBehaviour
  9. {
  10. private static SDKGlobalConfigTranslation mInstance;
  11. public static SDKGlobalConfigTranslation getInstance
  12. {
  13. get
  14. {
  15. if (mInstance == null)
  16. {
  17. mInstance = new GameObject("SDKGlobalConfigurationAsset").AddComponent<SDKGlobalConfigTranslation>();
  18. }
  19. return mInstance;
  20. }
  21. }
  22. SDKGlobalConfiguration SDKGlobalConfiguration;
  23. public List<Section> Configs;
  24. private void Awake()
  25. {
  26. Configs = new List<Section>();
  27. if (SDKGlobalConfiguration == null)
  28. {
  29. SDKGlobalConfiguration = Resources.Load<SDKGlobalConfiguration>("SDKGlobalConfiguration");
  30. DebugMy.Log("Load SDKGlobalConfiguration!", this, true);
  31. if (SDKGlobalConfiguration == null)
  32. {
  33. DebugMy.Log("SDKGlobalConfiguration Not Exist !", this, true);
  34. }
  35. }
  36. if (SDKGlobalConfiguration)
  37. {
  38. Configs.Add(new Section()
  39. {
  40. section = "RecorderDetector",
  41. KEY_VALUE = new List<KEY_VALUE>(){
  42. new KEY_VALUE()
  43. {
  44. Name = "IsRecording",
  45. Value = GetBool(SDKGlobalConfiguration.RecorderDetectorSettings.IsRecording)
  46. }
  47. }
  48. });
  49. Configs.Add(new Section()
  50. {
  51. section = "BatteryDetector",
  52. KEY_VALUE = new List<KEY_VALUE>(){
  53. new KEY_VALUE()
  54. {
  55. Name = "IsCharging",
  56. Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsCharging)
  57. },
  58. new KEY_VALUE()
  59. {
  60. Name = "Under20",
  61. Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.Under20)
  62. },
  63. new KEY_VALUE()
  64. {
  65. Name = "Under15",
  66. Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.Under15)
  67. },
  68. new KEY_VALUE()
  69. {
  70. Name = "Under10",
  71. Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.Under10)
  72. },
  73. new KEY_VALUE()
  74. {
  75. Name = "Under5",
  76. Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.Under5)
  77. },
  78. new KEY_VALUE()
  79. {
  80. Name = "Under1",
  81. Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.Under1)
  82. },
  83. new KEY_VALUE()
  84. {
  85. Name = "IsRightConnect",
  86. Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsRightConnect)
  87. },
  88. new KEY_VALUE()
  89. {
  90. Name = "IsRightUnconnecting",
  91. Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsRightUnconnecting)
  92. },
  93. new KEY_VALUE()
  94. {
  95. Name = "IsRightLow",
  96. Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsRightLow)
  97. },
  98. new KEY_VALUE()
  99. {
  100. Name = "IsLeftConnect",
  101. Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsLeftConnect)
  102. },
  103. new KEY_VALUE()
  104. {
  105. Name = "IsLeftUnconnecting",
  106. Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsLeftUnconnecting)
  107. },
  108. new KEY_VALUE()
  109. {
  110. Name = "IsLeftLow",
  111. Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsLeftLow)
  112. },
  113. new KEY_VALUE()
  114. {
  115. Name = "IsHandTracking",
  116. Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsHandTracking)
  117. }
  118. }
  119. });
  120. Configs.Add(new Section()
  121. {
  122. section = "Module_SafetyArea",
  123. KEY_VALUE = new List<KEY_VALUE>(){
  124. new KEY_VALUE()
  125. {
  126. Name = "Height",
  127. Value = SDKGlobalConfiguration.SafetyAreaSettings.SafetyAreaHeight.ToString()
  128. },
  129. }
  130. }) ;
  131. }
  132. }
  133. private string GetBool(bool value)
  134. {
  135. if (value == true)
  136. {
  137. return "1";
  138. }
  139. else return "0";
  140. }
  141. private string GetList(string[] list)
  142. {
  143. string result = "[\""+String.Join("\",\"", list)+"\"]";
  144. return result;
  145. }
  146. private string IfInRange(int min, int max,int num)
  147. {
  148. if ((num > min) && (num <= max))
  149. {
  150. return "1";
  151. }
  152. else return "0";
  153. }
  154. }
  155. }