VREventText.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. public class VREventText : MonoBehaviour
  5. {
  6. private void Awake()
  7. {
  8. this.m_txEventName = base.transform.Find("Canvas/Text").GetComponent<Text>();
  9. this.m_txGauge = base.transform.Find("Canvas/Gauge").GetComponent<UGuiRule>();
  10. this.m_txEventName.gameObject.SetActive(this.m_bEnable);
  11. this.m_txGauge.gameObject.SetActive(this.m_bEnable);
  12. this.UpdateEnableText();
  13. }
  14. public void SetEventName(string f_strEventName)
  15. {
  16. this.m_txEventName.text = f_strEventName;
  17. }
  18. public void UseGauge(bool f_bUse)
  19. {
  20. this.m_txGauge.gameObject.SetActive(f_bUse);
  21. this.m_bUseGauge = f_bUse;
  22. }
  23. public void SetGaugeRate(float f_fRate)
  24. {
  25. this.m_txGauge.Range = 1f;
  26. f_fRate = Mathf.Min(1f, Mathf.Max(f_fRate, 0f));
  27. this.m_txGauge.Range = 1f - 0.5f * f_fRate;
  28. }
  29. public void Show(VREventText.TYPE f_eType, string f_strEventName, float f_fRate = 0f)
  30. {
  31. this.m_unTypeFlag |= (uint)f_eType;
  32. this.SetEventName(f_strEventName);
  33. this.UseGauge(true);
  34. this.SetGaugeRate(f_fRate);
  35. this.UpdateEnableText();
  36. }
  37. public void Hide(VREventText.TYPE f_eType)
  38. {
  39. this.m_unTypeFlag &= (uint)(~(uint)f_eType);
  40. this.UpdateEnableText();
  41. }
  42. private void UpdateEnableText()
  43. {
  44. bool flag = this.m_unTypeFlag != 0U;
  45. if (this.m_bEnable != flag)
  46. {
  47. this.m_txEventName.gameObject.SetActive(flag);
  48. this.m_txGauge.gameObject.SetActive(flag);
  49. this.m_bEnable = flag;
  50. }
  51. }
  52. private void Update()
  53. {
  54. this.UpdateEnableText();
  55. }
  56. private Text m_txEventName;
  57. private UGuiRule m_txGauge;
  58. private VREventText.dgCallBackEvent m_dgCallBack;
  59. private bool m_bUseGauge;
  60. private uint m_unTypeFlag;
  61. private bool m_bEnable;
  62. public delegate void dgCallBackEvent();
  63. public enum TYPE
  64. {
  65. CHOICES = 1,
  66. GRAB,
  67. LOOK = 4
  68. }
  69. }