GetCloudDebugStatistics.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*===============================================================================
  2. Copyright (C) 2022 Immersal - Part of Hexagon. All Rights Reserved.
  3. This file is part of the Immersal SDK.
  4. The Immersal SDK cannot be copied, distributed, or made available to
  5. third-parties for commercial purposes without written permission of Immersal Ltd.
  6. Contact sdk@immersal.com for licensing requests.
  7. ===============================================================================*/
  8. using UnityEngine;
  9. using Immersal.AR;
  10. using TMPro;
  11. namespace Immersal.Samples.Mapping
  12. {
  13. [RequireComponent(typeof(TextMeshProUGUI))]
  14. public class GetCloudDebugStatistics : MonoBehaviour
  15. {
  16. private enum DebugMode {imageCount, inQueue, posesFound};
  17. private TextMeshProUGUI textMeshProUGUI;
  18. private ImmersalSDK m_Sdk;
  19. [SerializeField]
  20. private DebugMode debugMode = DebugMode.imageCount;
  21. [SerializeField]
  22. private string textAppend = "";
  23. private MapperBase mapper;
  24. void Start ()
  25. {
  26. textMeshProUGUI = GetComponent<TextMeshProUGUI>();
  27. m_Sdk = ImmersalSDK.Instance;
  28. mapper = UnityEngine.Object.FindObjectOfType<MapperBase>();
  29. }
  30. void Update ()
  31. {
  32. if (mapper != null && textMeshProUGUI != null && m_Sdk != null)
  33. {
  34. MapperStats ms = mapper.stats;
  35. LocalizerStats ls = m_Sdk.Localizer.stats;
  36. switch (debugMode)
  37. {
  38. case DebugMode.imageCount:
  39. textMeshProUGUI.text = string.Format("{0} {1}", textAppend, ms.imageCount);
  40. break;
  41. case DebugMode.inQueue:
  42. textMeshProUGUI.text = string.Format("{0} {1}", textAppend, ms.queueLen);
  43. break;
  44. case DebugMode.posesFound:
  45. textMeshProUGUI.text = string.Format("{0} {1}/{2}", textAppend, ls.localizationSuccessCount, ls.localizationAttemptCount);
  46. break;
  47. }
  48. }
  49. }
  50. }
  51. }