CanvasCollection.cs 818 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using UnityEngine;
  7. namespace SC.XR.Unity.Module_InputSystem {
  8. /// <summary>
  9. /// For SCInputModule know how many Canvas will be Detect, Canvas don't add the Component will ignor by SCInputModule
  10. /// </summary>
  11. public class CanvasCollection : MonoBehaviour {
  12. public static List<Canvas> CanvasList = new List<Canvas>();
  13. Canvas canvas;
  14. void OnEnable() {
  15. canvas = GetComponent<Canvas>();
  16. if(canvas) {
  17. CanvasList.Add(canvas);
  18. }
  19. }
  20. void OnDisable() {
  21. if(canvas) {
  22. CanvasList.Remove(canvas);
  23. canvas.worldCamera = null;
  24. }
  25. }
  26. }
  27. }