NRMultiDisplayManager.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /****************************************************************************
  2. * Copyright 2019 Nreal Techonology Limited. All rights reserved.
  3. *
  4. * This file is part of NRSDK.
  5. *
  6. * https://www.nreal.ai/
  7. *
  8. *****************************************************************************/
  9. namespace NRKernal
  10. {
  11. using UnityEngine;
  12. /// <summary> Manager for multi-displays. </summary>
  13. [HelpURL("https://developer.nreal.ai/develop/unity/customize-phone-controller")]
  14. public class NRMultiDisplayManager : MonoBehaviour
  15. {
  16. /// <summary> The default virtual displayer. </summary>
  17. [SerializeField] GameObject m_DefaultVirtualDisplayer;
  18. private NRVirtualDisplayer m_VirtualDisplayer;
  19. private void Start()
  20. {
  21. m_VirtualDisplayer = FindObjectOfType<NRVirtualDisplayer>();
  22. // Use the customise virtualdisplay if find one.
  23. if (m_VirtualDisplayer != null)
  24. {
  25. return;
  26. }
  27. // Use the default virtual display if can not find one.
  28. #if UNITY_EDITOR
  29. Instantiate(m_DefaultVirtualDisplayer);
  30. #else
  31. var virtualDisplayer = new GameObject("NRVirtualDisplayer").AddComponent<NRVirtualDisplayer>();
  32. GameObject.DontDestroyOnLoad(virtualDisplayer.gameObject);
  33. #endif
  34. }
  35. }
  36. }