HandleManager.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System;
  2. using SRF;
  3. using UnityEngine;
  4. namespace SRDebugger.UI.Other
  5. {
  6. public class HandleManager : SRMonoBehaviour
  7. {
  8. private void Start()
  9. {
  10. if (!this._hasSet)
  11. {
  12. this.SetAlignment(this.DefaultAlignment);
  13. }
  14. }
  15. public void SetAlignment(PinAlignment alignment)
  16. {
  17. this._hasSet = true;
  18. switch (alignment)
  19. {
  20. case PinAlignment.TopLeft:
  21. case PinAlignment.TopRight:
  22. this.SetActive(this.BottomHandle, true);
  23. this.SetActive(this.TopHandle, false);
  24. this.SetActive(this.TopLeftHandle, false);
  25. this.SetActive(this.TopRightHandle, false);
  26. break;
  27. case PinAlignment.BottomLeft:
  28. case PinAlignment.BottomRight:
  29. this.SetActive(this.BottomHandle, false);
  30. this.SetActive(this.TopHandle, true);
  31. this.SetActive(this.BottomLeftHandle, false);
  32. this.SetActive(this.BottomRightHandle, false);
  33. break;
  34. }
  35. switch (alignment)
  36. {
  37. case PinAlignment.TopLeft:
  38. case PinAlignment.BottomLeft:
  39. this.SetActive(this.LeftHandle, false);
  40. this.SetActive(this.RightHandle, true);
  41. this.SetActive(this.TopLeftHandle, false);
  42. this.SetActive(this.BottomLeftHandle, false);
  43. break;
  44. case PinAlignment.TopRight:
  45. case PinAlignment.BottomRight:
  46. this.SetActive(this.LeftHandle, true);
  47. this.SetActive(this.RightHandle, false);
  48. this.SetActive(this.TopRightHandle, false);
  49. this.SetActive(this.BottomRightHandle, false);
  50. break;
  51. }
  52. switch (alignment)
  53. {
  54. case PinAlignment.TopLeft:
  55. this.SetActive(this.BottomLeftHandle, false);
  56. this.SetActive(this.BottomRightHandle, true);
  57. break;
  58. case PinAlignment.TopRight:
  59. this.SetActive(this.BottomLeftHandle, true);
  60. this.SetActive(this.BottomRightHandle, false);
  61. break;
  62. case PinAlignment.BottomLeft:
  63. this.SetActive(this.TopLeftHandle, false);
  64. this.SetActive(this.TopRightHandle, true);
  65. break;
  66. case PinAlignment.BottomRight:
  67. this.SetActive(this.TopLeftHandle, true);
  68. this.SetActive(this.TopRightHandle, false);
  69. break;
  70. }
  71. }
  72. private void SetActive(GameObject obj, bool active)
  73. {
  74. if (obj == null)
  75. {
  76. return;
  77. }
  78. obj.SetActive(active);
  79. }
  80. private bool _hasSet;
  81. public GameObject BottomHandle;
  82. public GameObject BottomLeftHandle;
  83. public GameObject BottomRightHandle;
  84. public PinAlignment DefaultAlignment;
  85. public GameObject LeftHandle;
  86. public GameObject RightHandle;
  87. public GameObject TopHandle;
  88. public GameObject TopLeftHandle;
  89. public GameObject TopRightHandle;
  90. }
  91. }