| | 1 | | using DCL.Helpers; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.UI; |
| | 4 | |
|
| | 5 | | public class FriendsListToggleButton : MonoBehaviour |
| | 6 | | { |
| | 7 | | public bool toggleOnAwake = false; |
| | 8 | | public Button toggleButton; |
| | 9 | | public Transform toggleButtonIcon; |
| | 10 | | public RectTransform containerRectTransform; |
| | 11 | |
|
| | 12 | | void Awake() |
| | 13 | | { |
| 13 | 14 | | toggleButton.onClick.AddListener(Toggle); |
| | 15 | |
|
| 13 | 16 | | if (toggleOnAwake) |
| 13 | 17 | | Toggle(); |
| 13 | 18 | | } |
| | 19 | |
|
| | 20 | | void Toggle() |
| | 21 | | { |
| 13 | 22 | | containerRectTransform.gameObject.SetActive(!containerRectTransform.gameObject.activeSelf); |
| 13 | 23 | | toggleButtonIcon.localScale = new Vector3(toggleButtonIcon.localScale.x, -toggleButtonIcon.localScale.y, 1f); |
| 13 | 24 | | Utils.ForceRebuildLayoutImmediate(containerRectTransform); |
| 13 | 25 | | } |
| | 26 | | } |