CanvasTargetCollector.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 System.Collections;
  12. using System.Collections.Generic;
  13. using UnityEngine;
  14. /// <summary> The canvas target collector. </summary>
  15. public class CanvasTargetCollector : MonoBehaviour
  16. {
  17. /// <summary> The canvases. </summary>
  18. private static readonly List<ICanvasRaycastTarget> canvases = new List<ICanvasRaycastTarget>();
  19. /// <summary> Adds a target. </summary>
  20. /// <param name="obj"> The object.</param>
  21. public static void AddTarget(ICanvasRaycastTarget obj)
  22. {
  23. if(obj != null)
  24. canvases.Add(obj);
  25. }
  26. /// <summary> Removes the target described by obj. </summary>
  27. /// <param name="obj"> The object.</param>
  28. public static void RemoveTarget(ICanvasRaycastTarget obj)
  29. {
  30. if (obj != null)
  31. canvases.Remove(obj);
  32. }
  33. /// <summary> Gets the canvases. </summary>
  34. /// <returns> The canvases. </returns>
  35. public static List<ICanvasRaycastTarget> GetCanvases()
  36. {
  37. return canvases;
  38. }
  39. }
  40. }