| | 1 | | using System; |
| | 2 | | using DCL.Helpers; |
| | 3 | | using UnityEngine; |
| | 4 | | using UnityEngine.UI; |
| | 5 | |
|
| | 6 | | internal class SectionProjectScenesView : MonoBehaviour, IDisposable |
| | 7 | | { |
| | 8 | | public event Action OnScrollRectValueChanged; |
| | 9 | |
|
| | 10 | | [SerializeField] public Transform scenesCardContainer; |
| | 11 | | [SerializeField] public ScrollRect scrollRect; |
| | 12 | |
|
| | 13 | | private bool isDestroyed = false; |
| | 14 | |
|
| | 15 | | public void SetParent(Transform parent) |
| | 16 | | { |
| 0 | 17 | | transform.SetParent(parent); |
| 0 | 18 | | transform.ResetLocalTRS(); |
| 0 | 19 | | } |
| | 20 | |
|
| 0 | 21 | | public void SetActive(bool active) { gameObject.SetActive(active); } |
| | 22 | |
|
| 2 | 23 | | public void ResetScrollRect() { scrollRect.verticalNormalizedPosition = 1; } |
| | 24 | |
|
| | 25 | | public void Dispose() |
| | 26 | | { |
| 1 | 27 | | if (!isDestroyed) |
| | 28 | | { |
| 1 | 29 | | Destroy(gameObject); |
| | 30 | | } |
| 1 | 31 | | } |
| | 32 | |
|
| 4 | 33 | | private void Awake() { scrollRect.onValueChanged.AddListener(OnScrollValueChanged); } |
| | 34 | |
|
| | 35 | | private void OnDestroy() |
| | 36 | | { |
| 2 | 37 | | isDestroyed = true; |
| 2 | 38 | | scrollRect.onValueChanged.RemoveListener(OnScrollValueChanged); |
| 2 | 39 | | } |
| | 40 | |
|
| 0 | 41 | | private void OnScrollValueChanged(Vector2 value) { OnScrollRectValueChanged?.Invoke(); } |
| | 42 | | } |