| | 1 | | using UnityEngine; |
| | 2 | | using UnityEngine.UI; |
| | 3 | |
|
| | 4 | | public class DebugSection : MonoBehaviour |
| | 5 | | { |
| | 6 | | [SerializeField] private Button closeSectionButton; |
| | 7 | | [SerializeField] private GameObject sectionContent; |
| | 8 | |
|
| | 9 | | private RectTransform rootTransform; |
| | 10 | | private RectTransform closeSectionButtonTransform; |
| | 11 | | void Start() |
| | 12 | | { |
| 0 | 13 | | rootTransform = transform.parent.GetComponent<RectTransform>(); |
| 0 | 14 | | closeSectionButton.onClick.AddListener(CloseSection); |
| 0 | 15 | | closeSectionButtonTransform = closeSectionButton.GetComponent<RectTransform>(); |
| 0 | 16 | | } |
| | 17 | | private void CloseSection() |
| | 18 | | { |
| 0 | 19 | | sectionContent.SetActive(!sectionContent.activeSelf); |
| 0 | 20 | | closeSectionButtonTransform.Rotate(Vector3.forward,180); |
| 0 | 21 | | LayoutRebuilder.ForceRebuildLayoutImmediate(rootTransform); |
| 0 | 22 | | } |
| | 23 | |
|
| | 24 | | private void OnDestroy() |
| | 25 | | { |
| 0 | 26 | | closeSectionButton.onClick.RemoveAllListeners(); |
| 0 | 27 | | } |
| | 28 | |
|
| | 29 | | } |