DropDownListHelper.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. using UnityEngine.EventSystems;
  13. using UnityEngine.UI;
  14. public class DropDownListHelper : Dropdown
  15. {
  16. public override void OnPointerClick(PointerEventData eventData)
  17. {
  18. base.OnPointerClick(eventData);
  19. RemoveUnityCanvas();
  20. }
  21. private void RemoveUnityCanvas()
  22. {
  23. var raycasttarget = gameObject.GetComponentsInChildren<GraphicRaycaster>();
  24. foreach (var item in raycasttarget)
  25. {
  26. GameObject.Destroy(item);
  27. }
  28. var canvas = gameObject.GetComponentsInChildren<Canvas>();
  29. foreach (var item in canvas)
  30. {
  31. GameObject.Destroy(item);
  32. }
  33. }
  34. }
  35. }