WaypointsUI.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.Collections;
  9. using System.Collections.Generic;
  10. using UnityEngine;
  11. using UnityEngine.UI;
  12. namespace Immersal.Samples.Navigation
  13. {
  14. public class WaypointsUI : MonoBehaviour
  15. {
  16. [SerializeField]
  17. private GameObject m_EditModePanel = null;
  18. [SerializeField]
  19. private GameObject m_EditModeButton = null;
  20. [SerializeField]
  21. private GameObject m_SettingsButton = null;
  22. [SerializeField]
  23. private GameObject m_SettingsPanel = null;
  24. private enum UIState { Navigation, EditMode, Settings };
  25. private UIState m_State = UIState.Navigation;
  26. void Start()
  27. {
  28. ChangeState(UIState.Navigation);
  29. }
  30. private void InitializeUI()
  31. {
  32. }
  33. public void ToggleEditMode()
  34. {
  35. if (m_State == UIState.EditMode)
  36. {
  37. m_State = UIState.Navigation;
  38. }
  39. else
  40. {
  41. m_State = UIState.EditMode;
  42. }
  43. ChangeState(m_State);
  44. }
  45. public void ToggleSettingsPanel()
  46. {
  47. if (m_State == UIState.Settings)
  48. {
  49. m_State = UIState.Navigation;
  50. }
  51. else
  52. {
  53. m_State = UIState.Settings;
  54. }
  55. ChangeState(m_State);
  56. }
  57. private void ChangeState(UIState state)
  58. {
  59. switch (state)
  60. {
  61. case UIState.Navigation:
  62. Immersal.Samples.Navigation.NavigationManager.Instance.inEditMode = false;
  63. m_SettingsPanel.SetActive(false);
  64. m_EditModePanel.SetActive(false);
  65. m_SettingsButton.SetActive(true);
  66. m_EditModeButton.SetActive(true);
  67. break;
  68. case UIState.EditMode:
  69. Immersal.Samples.Navigation.NavigationManager.Instance.inEditMode = true;
  70. m_SettingsPanel.SetActive(false);
  71. m_EditModePanel.SetActive(true);
  72. m_SettingsButton.SetActive(true);
  73. m_EditModeButton.SetActive(true);
  74. break;
  75. case UIState.Settings:
  76. Immersal.Samples.Navigation.NavigationManager.Instance.inEditMode = false;
  77. m_SettingsPanel.SetActive(true);
  78. m_EditModePanel.SetActive(false);
  79. m_SettingsButton.SetActive(true);
  80. m_EditModeButton.SetActive(true);
  81. break;
  82. default:
  83. break;
  84. }
  85. }
  86. }
  87. }