TrackableFoundTest.cs 963 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using NRKernal;
  2. using UnityEngine;
  3. /// <summary> A trackable found test. </summary>
  4. public class TrackableFoundTest : MonoBehaviour
  5. {
  6. /// <summary> The observer. </summary>
  7. public TrackableObserver Observer;
  8. /// <summary> The object. </summary>
  9. public GameObject Obj;
  10. /// <summary> Starts this object. </summary>
  11. void Start()
  12. {
  13. #if !UNITY_EDITOR
  14. Destroy(GameObject.Find("EmulatorRoom"));
  15. #endif
  16. Obj.SetActive(false);
  17. Observer.FoundEvent += Found;
  18. Observer.LostEvent += Lost;
  19. }
  20. /// <summary> Founds. </summary>
  21. /// <param name="pos"> The position.</param>
  22. /// <param name="qua"> The qua.</param>
  23. private void Found(Vector3 pos, Quaternion qua)
  24. {
  25. Obj.transform.position = pos;
  26. Obj.transform.rotation = qua;
  27. Obj.SetActive(true);
  28. }
  29. /// <summary> Losts this object. </summary>
  30. private void Lost()
  31. {
  32. Obj.SetActive(false);
  33. }
  34. }