EnableIfOpenCVNotDetected.cs 693 B

123456789101112131415161718192021222324252627
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. /// <summary>
  6. /// Enables the attached GameObject if the OpenCV for Unity package isn't detected.
  7. /// Used in the OpenCV ArUco example scene to indicate the package is missing via a Text object on the canvas.
  8. /// </summary>
  9. public class EnableIfOpenCVNotDetected : MonoBehaviour
  10. {
  11. public GameObject objectToEnable;
  12. void Awake ()
  13. {
  14. #if !ZED_OPENCV_FOR_UNITY
  15. if(!objectToEnable)
  16. {
  17. objectToEnable = GetComponentInChildren<Text>().gameObject;
  18. }
  19. objectToEnable.gameObject.SetActive(true);
  20. #endif
  21. }
  22. }