BasePoseProvider.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. #if ENABLE_VR || ENABLE_AR
  6. using UnityEngine.XR;
  7. using UnityEngine.SpatialTracking;
  8. namespace UnityEngine.Experimental.XR.Interaction
  9. {
  10. /// <summary>
  11. /// The BasePoseProvider type is used as the base interface for all "Pose Providers"
  12. /// Implementing this abstract class will allow the Pose Provider to be linked to a Tracked Pose Driver.
  13. /// </summary>
  14. [Serializable]
  15. public abstract class BasePoseProvider : MonoBehaviour
  16. {
  17. /// <summary> Gets the Pose value from the Pose Provider. returns NoData as this is a default implementation. Specializations will return the correct bitflags relating to the Pose data they are returning</summary>
  18. public virtual PoseDataFlags GetPoseFromProvider(out Pose output)
  19. {
  20. // disabling the obsolete warning/error here so that no error is generated by the use of this function.
  21. #pragma warning disable 618,619
  22. if(TryGetPoseFromProvider(out output))
  23. {
  24. return PoseDataFlags.Position | PoseDataFlags.Rotation;
  25. }
  26. #pragma warning restore 618,619
  27. return PoseDataFlags.NoData;
  28. }
  29. /// <summary>
  30. /// This function is provided for backwards compatibiltiy with the BasePoseProvider found in com.untiy.xr.legacyinputhelpers v1.3.X
  31. /// Please do not implement this function, instead use the new API via GetPoseFromProvider
  32. /// </summary>
  33. [System.Obsolete("This function is provided for backwards compatibiltiy with the BasePoseProvider found in com.untiy.xr.legacyinputhelpers v1.3.X Please do not implement this function, instead use the new API via GetPoseFromProvider",false)]
  34. public virtual bool TryGetPoseFromProvider(out Pose output)
  35. {
  36. output = Pose.identity;
  37. return false;
  38. }
  39. }
  40. }
  41. #endif