MappingUIManager.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 System;
  9. using UnityEngine;
  10. using UnityEngine.UI;
  11. using Immersal.Samples.Util;
  12. using TMPro;
  13. namespace Immersal.Samples.Mapping
  14. {
  15. public class MappingUIManager : MonoBehaviour
  16. {
  17. public WorkspaceManager workspaceManager;
  18. public VisualizeManager visualizeManager;
  19. public TextMeshProUGUI locationText = null;
  20. public TextMeshProUGUI vLocationText = null;
  21. public Toggle gpsToggle = null;
  22. //public Toggle nearbyMapsToggle = null;
  23. //public Toggle serverLocalizeToggle = null;
  24. [SerializeField]
  25. private HorizontalProgressBar m_ProgressBar = null;
  26. private enum UIState {Workspace, Visualize};
  27. private UIState uiState = UIState.Workspace;
  28. [SerializeField] private TextMeshProUGUI loggedInAsText = null;
  29. public void SwitchMode() {
  30. if (uiState == UIState.Workspace) {
  31. uiState = UIState.Visualize;
  32. } else {
  33. uiState = UIState.Workspace;
  34. }
  35. ChangeState(uiState);
  36. }
  37. public void ShowProgressBar()
  38. {
  39. m_ProgressBar.transform.GetComponent<Fader>().FadeIn();
  40. }
  41. public void HideProgressBar()
  42. {
  43. m_ProgressBar.transform.GetComponent<Fader>().FadeOut();
  44. }
  45. public void SetProgress(int value)
  46. {
  47. m_ProgressBar.currentValue = value;
  48. }
  49. public void ShowDebugConsole(bool value)
  50. {
  51. DebugConsole.Instance.Show(value);
  52. }
  53. public void LogoutButtonPressed()
  54. {
  55. LoginManager.Instance.Logout();
  56. }
  57. private void ChangeState(UIState state) {
  58. switch (state) {
  59. case UIState.Workspace:
  60. workspaceManager.gameObject.SetActive(true);
  61. visualizeManager.gameObject.SetActive(false);
  62. break;
  63. case UIState.Visualize:
  64. workspaceManager.gameObject.SetActive(false);
  65. visualizeManager.gameObject.SetActive(true);
  66. break;
  67. default:
  68. break;
  69. }
  70. }
  71. private void OnEnable()
  72. {
  73. loggedInAsText.text = "Logged in as " + PlayerPrefs.GetString("login");
  74. }
  75. private void OnDisable()
  76. {
  77. loggedInAsText.text = string.Empty;
  78. }
  79. private void Start()
  80. {
  81. ChangeState(uiState);
  82. m_ProgressBar.minValue = 0;
  83. m_ProgressBar.maxValue = 100;
  84. m_ProgressBar.currentValue = 0;
  85. }
  86. }
  87. }