ToggleMappingMode.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. namespace Immersal.Samples.Mapping
  10. {
  11. public class ToggleMappingMode : MonoBehaviour
  12. {
  13. public GameObject mappingUIPrefab;
  14. private GameObject m_MappingUI;
  15. public GameObject MappingUI
  16. {
  17. get { return m_MappingUI; }
  18. }
  19. void Start()
  20. {
  21. LoginManager loginManager = LoginManager.Instance;
  22. if (loginManager != null)
  23. {
  24. loginManager.OnLogin += EnableMappingMode;
  25. loginManager.OnLogout += DisableMappingMode;
  26. }
  27. }
  28. public void EnableMappingMode()
  29. {
  30. if (m_MappingUI == null)
  31. {
  32. m_MappingUI = Instantiate(mappingUIPrefab);
  33. }
  34. else
  35. {
  36. m_MappingUI.SetActive(true);
  37. }
  38. }
  39. public void DisableMappingMode()
  40. {
  41. if (m_MappingUI != null)
  42. {
  43. m_MappingUI.SetActive(false);
  44. }
  45. }
  46. }
  47. }