DisableUntilZEDReady.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using sl;
  5. /// <summary>
  6. /// Causes the attached GameObject to get disabled until a ZED camera finishes initializing.
  7. /// Used in the ZED Dark Room sample to synchronize the lights and music with the ZED's start.
  8. /// </summary>
  9. public class DisableUntilZEDReady : MonoBehaviour
  10. {
  11. /// <summary>
  12. /// The ZEDManager to wait for. If left empty, it will select the first ZED available.
  13. /// This may cause unwanted behavior if multiple ZEDManagers are in the scene.
  14. /// </summary>
  15. [Tooltip("The ZEDManager to wait for. If left empty, it will select the first ZED available. " +
  16. "This may cause unwanted behavior if multiple ZEDManagers are in the scene.")]
  17. public ZEDManager zedManager = null;
  18. // Use this for initialization
  19. void Awake()
  20. {
  21. if(!zedManager) zedManager = FindObjectOfType<ZEDManager> (); //Selects the first available ZEDManager if none was set before.
  22. if (zedManager) zedManager.OnZEDReady += EnableThisObject;
  23. }
  24. void EnableThisObject()
  25. {
  26. gameObject.SetActive(true);
  27. }
  28. }