MQTTSettings.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Reflection;
  5. using UnityEditor;
  6. using UnityEngine;
  7. using UnityEngine.XR;
  8. using UnityEditor.PackageManager;
  9. using UnityEditor.PackageManager.Requests;
  10. public class MQTTSettings
  11. {
  12. [MenuItem("GHZ/GHZXRPackage/MQTT")]
  13. public static void MQTTInit()
  14. {
  15. Debug.Log("MQTTInit");
  16. PlayerSet();
  17. }
  18. static void PlayerSet()
  19. {
  20. try
  21. {
  22. FileUtil.DeleteFileOrDirectory("Assets/MQTT");
  23. }
  24. catch
  25. {
  26. }
  27. string[] strlist = new string[3];
  28. strlist[0] = "https://gogs.ghz-tech.com:8843/GHzGlass/GHZMQTTXR.git";
  29. AddAndRemoveRequest rest = Client.AddAndRemove(strlist);
  30. while (!rest.IsCompleted)
  31. {
  32. Debug.Log("正在加载插件包:" + rest.Status.ToString());
  33. System.Threading.Thread.Sleep(500);
  34. // 等待PackageManager请求完成
  35. }
  36. // Client.Add("com.unity.xr.openxr");
  37. // ListRequest request = Client.List(true);
  38. // LoadSamplesSettings.PlayerLiveSamplesSet(request);
  39. }
  40. }