WorkspaceManager.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 System.Collections;
  10. using TMPro;
  11. namespace Immersal.Samples.Mapping
  12. {
  13. public class WorkspaceManager : MonoBehaviour
  14. {
  15. public MappingUIComponent captureButton = null;
  16. public TMP_InputField newMapName = null;
  17. public TMP_Dropdown detailLevelDropdown = null;
  18. [SerializeField]
  19. private MappingUIComponent m_OptionsButton = null;
  20. [SerializeField]
  21. public MappingUIComponent m_InfoPanel = null;
  22. [SerializeField]
  23. private GameObject m_OptionsScrollList = null;
  24. [SerializeField]
  25. private GameObject m_PromptDeleteData = null;
  26. [SerializeField]
  27. private GameObject m_PromptConstructMap = null;
  28. private enum UIState { Default, Options, DeleteData, SubmitNewMap };
  29. private UIState uiState = UIState.Default;
  30. public void Options() {
  31. if (uiState == UIState.Options) {
  32. uiState = UIState.Default;
  33. } else {
  34. uiState = UIState.Options;
  35. }
  36. ChangeState(uiState);
  37. }
  38. public void DeleteData() {
  39. if (uiState == UIState.DeleteData) {
  40. uiState = UIState.Default;
  41. } else {
  42. uiState = UIState.DeleteData;
  43. }
  44. ChangeState(uiState);
  45. }
  46. public void ConstructMap() {
  47. if (uiState == UIState.SubmitNewMap) {
  48. uiState = UIState.Default;
  49. } else {
  50. uiState = UIState.SubmitNewMap;
  51. }
  52. ChangeState(uiState);
  53. }
  54. public void DefaultView() {
  55. uiState = UIState.Default;
  56. ChangeState(uiState);
  57. }
  58. private void ChangeState(UIState state) {
  59. switch (state) {
  60. case UIState.Default:
  61. m_OptionsButton.Activate();
  62. captureButton.Activate();
  63. m_InfoPanel.Activate();
  64. m_OptionsScrollList.SetActive(false);
  65. m_PromptDeleteData.SetActive(false);
  66. m_PromptConstructMap.SetActive(false);
  67. m_InfoPanel.gameObject.SetActive(true);
  68. break;
  69. case UIState.Options:
  70. m_OptionsButton.Activate();
  71. captureButton.Disable();
  72. m_InfoPanel.Disable();
  73. m_OptionsScrollList.SetActive(true);
  74. m_PromptDeleteData.SetActive(false);
  75. m_PromptConstructMap.SetActive(false);
  76. m_InfoPanel.gameObject.SetActive(true);
  77. break;
  78. case UIState.DeleteData:
  79. m_OptionsButton.Disable();
  80. captureButton.Disable();
  81. m_InfoPanel.Disable();
  82. m_OptionsScrollList.SetActive(false);
  83. m_PromptDeleteData.SetActive(true);
  84. m_PromptConstructMap.SetActive(false);
  85. m_InfoPanel.gameObject.SetActive(true);
  86. break;
  87. case UIState.SubmitNewMap:
  88. m_OptionsButton.Disable();
  89. captureButton.Disable();
  90. m_InfoPanel.Disable();
  91. m_OptionsScrollList.SetActive(false);
  92. m_PromptDeleteData.SetActive(false);
  93. m_PromptConstructMap.SetActive(true);
  94. m_InfoPanel.gameObject.SetActive(true);
  95. break;
  96. default:
  97. break;
  98. }
  99. }
  100. private void Start() {
  101. ChangeState(uiState);
  102. }
  103. }
  104. }