CircleListSelectUI.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using UnityEngine;
  3. public class CircleListSelectUI : MonoBehaviour
  4. {
  5. public AVRController controller { get; set; }
  6. public CircleCommandUI circleCommandUI
  7. {
  8. get
  9. {
  10. return this.m_CircleCommandUI;
  11. }
  12. }
  13. private void Start()
  14. {
  15. CircleCommandUI circleCommandUI = this.m_CircleCommandUI;
  16. circleCommandUI.funcDecide = (Func<bool>)Delegate.Combine(circleCommandUI.funcDecide, new Func<bool>(this.CallbackDecide));
  17. }
  18. private void Update()
  19. {
  20. if (this.controller == null)
  21. {
  22. return;
  23. }
  24. AVRControllerButtons vrcontrollerButtons = this.controller.VRControllerButtons;
  25. Vector2 axis = vrcontrollerButtons.GetAxis();
  26. if (axis.sqrMagnitude >= 0.2f)
  27. {
  28. this.m_CircleCommandUI.UpdateSelect(axis);
  29. this.SetActiveUI(true);
  30. }
  31. if (vrcontrollerButtons.GetPressDown(AVRControllerButtons.BTN.VIRTUAL_R_CLICK))
  32. {
  33. this.SetActiveUI(false);
  34. }
  35. }
  36. private void SetActiveUI(GameObject UI, bool active)
  37. {
  38. if (UI.activeSelf && !active)
  39. {
  40. UI.SetActive(false);
  41. }
  42. else if (!UI.activeSelf && active)
  43. {
  44. UI.SetActive(true);
  45. }
  46. }
  47. public void SetActiveUI(bool active)
  48. {
  49. this.SetActiveUI(this.m_CircleCommandUI.gameObject, active);
  50. }
  51. private bool CallbackDecide()
  52. {
  53. if (this.controller == null)
  54. {
  55. return false;
  56. }
  57. AVRControllerButtons vrcontrollerButtons = this.controller.VRControllerButtons;
  58. return vrcontrollerButtons.GetPressDown(AVRControllerButtons.BTN.VIRTUAL_L_CLICK);
  59. }
  60. [SerializeField]
  61. private CircleCommandUI m_CircleCommandUI;
  62. }