ShowInfoTipManager.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using SC.XR.Unity.Module_InputSystem;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using TMPro;
  5. using UnityEngine;
  6. public class ShowInfoTipManager : MonoSingleton<ShowInfoTipManager>
  7. {
  8. public GameObject go;
  9. public TextMeshProUGUI text;
  10. public void showTip(string msg,bool isHead=true)
  11. {
  12. if(!isHead)
  13. {
  14. if (WindowsManager.Instance.tipInfoGameObject != null && GSXR_Transform.position != null)
  15. {
  16. WindowsManager.Instance.tipInfoGameObject.transform.parent = GSXR_Transform;
  17. WindowsManager.Instance.tipInfoGameObject.transform.position = GSXR_Transform.position;
  18. WindowsManager.Instance.tipInfoGameObject.transform.LookAt(OpenXRCamera.Instance.head);
  19. }
  20. }
  21. else
  22. {
  23. if (WindowsManager.Instance.tipInfoGameObject != null && GSXR_Transform.position != null)
  24. {
  25. WindowsManager.Instance.tipInfoGameObject.transform.parent = OpenXRCamera.Instance.head;
  26. WindowsManager.Instance.tipInfoGameObject.transform.localPosition = new Vector3(0, 0, 1.5f);
  27. WindowsManager.Instance.tipInfoGameObject.transform.localEulerAngles = new Vector3(0,180,0);
  28. // WindowsManager.Instance.tipInfoGameObject.transform.LookAt(OpenXRCamera.Instance.head);
  29. }
  30. }
  31. go.gameObject.SetActive(true);
  32. text.text = msg;
  33. }
  34. ///API-No.61
  35. /// <summary>
  36. /// 输入设备Cursor的位置,优先级为Head/BTRight/BTLeft/GTRight/GTLeft/GGTRight/GGLeft
  37. /// </summary>
  38. public static Transform GSXR_Transform
  39. {
  40. get
  41. {
  42. if (!Module_InputSystem.instance.GetInputDeviceStatus(InputDeviceType.KS))
  43. {
  44. return API_GSXR_Module_InputSystem_Head.GSXR_Get_HeadCursor.transform;
  45. }
  46. else
  47. {
  48. return API_GSXR_Module_InputSystem_KS.GSXR_Get_KSCursor(API_GSXR_Module_InputSystem_KS.GCType.Right).transform;
  49. }
  50. return null;
  51. }
  52. }
  53. public void closeTip()
  54. {
  55. go.gameObject.SetActive(false);
  56. }
  57. }