123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- using SC.XR.Unity;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace SC.XR.Unity
- {
- public class SDKGlobalConfigTranslation : MonoBehaviour
- {
- private static SDKGlobalConfigTranslation mInstance;
- public static SDKGlobalConfigTranslation getInstance
- {
- get
- {
- if (mInstance == null)
- {
- mInstance = new GameObject("SDKGlobalConfigurationAsset").AddComponent<SDKGlobalConfigTranslation>();
- }
- return mInstance;
- }
- }
- SDKGlobalConfiguration SDKGlobalConfiguration;
- public List<Section> Configs;
- private void Awake()
- {
- Configs = new List<Section>();
- if (SDKGlobalConfiguration == null)
- {
- SDKGlobalConfiguration = Resources.Load<SDKGlobalConfiguration>("SDKGlobalConfiguration");
- DebugMy.Log("Load SDKGlobalConfiguration!", this, true);
- if (SDKGlobalConfiguration == null)
- {
- DebugMy.Log("SDKGlobalConfiguration Not Exist !", this, true);
- }
- }
- if (SDKGlobalConfiguration)
- {
- Configs.Add(new Section()
- {
- section = "RecorderDetector",
- KEY_VALUE = new List<KEY_VALUE>(){
- new KEY_VALUE()
- {
- Name = "IsRecording",
- Value = GetBool(SDKGlobalConfiguration.RecorderDetectorSettings.IsRecording)
- }
- }
- });
- Configs.Add(new Section()
- {
- section = "BatteryDetector",
- KEY_VALUE = new List<KEY_VALUE>(){
- new KEY_VALUE()
- {
- Name = "IsCharging",
- Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsCharging)
- },
- new KEY_VALUE()
- {
- Name = "Under20",
- Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.Under20)
- },
- new KEY_VALUE()
- {
- Name = "Under15",
- Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.Under15)
- },
- new KEY_VALUE()
- {
- Name = "Under10",
- Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.Under10)
- },
- new KEY_VALUE()
- {
- Name = "Under5",
- Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.Under5)
- },
- new KEY_VALUE()
- {
- Name = "Under1",
- Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.Under1)
- },
- new KEY_VALUE()
- {
- Name = "IsRightConnect",
- Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsRightConnect)
- },
- new KEY_VALUE()
- {
- Name = "IsRightUnconnecting",
- Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsRightUnconnecting)
- },
- new KEY_VALUE()
- {
- Name = "IsRightLow",
- Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsRightLow)
- },
- new KEY_VALUE()
- {
- Name = "IsLeftConnect",
- Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsLeftConnect)
- },
- new KEY_VALUE()
- {
- Name = "IsLeftUnconnecting",
- Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsLeftUnconnecting)
- },
- new KEY_VALUE()
- {
- Name = "IsLeftLow",
- Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsLeftLow)
- },
- new KEY_VALUE()
- {
- Name = "IsHandTracking",
- Value = GetBool(SDKGlobalConfiguration.BatteryDetectorSettings.IsHandTracking)
- }
- }
- });
- Configs.Add(new Section()
- {
- section = "Module_SafetyArea",
- KEY_VALUE = new List<KEY_VALUE>(){
- new KEY_VALUE()
- {
- Name = "Height",
- Value = SDKGlobalConfiguration.SafetyAreaSettings.SafetyAreaHeight.ToString()
- },
- }
- }) ;
- }
- }
- private string GetBool(bool value)
- {
- if (value == true)
- {
- return "1";
- }
- else return "0";
- }
- private string GetList(string[] list)
- {
- string result = "[\""+String.Join("\",\"", list)+"\"]";
- return result;
- }
- private string IfInRange(int min, int max,int num)
- {
- if ((num > min) && (num <= max))
- {
- return "1";
- }
- else return "0";
- }
- }
- }
|