UIInteractionHandle.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //==========================================================
  2. //
  3. // Copyright (c) Guangzhou Shixiang Technology Co.,Ltd.
  4. // All rights reserved.
  5. //
  6. //==========================================================
  7. using UnityEngine;
  8. using UnityEngine.UI;
  9. public class UIInteractionHandle : MonoBehaviour
  10. {
  11. [SerializeField]
  12. private Button _buttonAdd;
  13. [SerializeField]
  14. private Button _buttonSub;
  15. [SerializeField]
  16. private Button _buttonChangeColor;
  17. [SerializeField]
  18. private Button _buttonRotate;
  19. [SerializeField]
  20. private Slider _sliderScale;
  21. [SerializeField]
  22. private Toggle _toggleLockColor;
  23. [SerializeField]
  24. private Dropdown _Dropdown;
  25. void Start()
  26. {
  27. if (_buttonAdd != null)
  28. {
  29. _buttonAdd.onClick.AddListener(Add);
  30. }
  31. if (_buttonSub != null)
  32. {
  33. _buttonSub.onClick.AddListener(Sub);
  34. }
  35. if (_buttonChangeColor != null)
  36. {
  37. _buttonChangeColor.onClick.AddListener(ChangeColor);
  38. }
  39. if (_buttonRotate != null)
  40. {
  41. _buttonRotate.onClick.AddListener(Rotate);
  42. }
  43. if (_sliderScale != null)
  44. {
  45. _sliderScale.onValueChanged.AddListener(delegate
  46. {
  47. SliderValueChanged();
  48. });
  49. }
  50. _toggleLockColor.isOn = false;
  51. if (_toggleLockColor != null)
  52. {
  53. _toggleLockColor.onValueChanged.AddListener(delegate
  54. {
  55. ToggleValueChanged();
  56. });
  57. }
  58. }
  59. private void Add()
  60. {
  61. InteractionObjManager.Instance.AddAll();
  62. }
  63. private void Sub()
  64. {
  65. InteractionObjManager.Instance.SubAll();
  66. }
  67. private void ChangeColor()
  68. {
  69. InteractionObjManager.Instance.ChangeColorAll();
  70. }
  71. private void Rotate()
  72. {
  73. InteractionObjManager.Instance.RotateAll();
  74. }
  75. private void SliderValueChanged()
  76. {
  77. float value = _sliderScale.value;
  78. InteractionObjManager.Instance.ScaleAll(value);
  79. }
  80. private void ToggleValueChanged()
  81. {
  82. bool isLock = _toggleLockColor.isOn;
  83. InteractionObjManager.Instance.LockColorAll(isLock);
  84. }
  85. }