| | 1 | | using System; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | namespace DCL.Components |
| | 5 | | { |
| | 6 | | public class ScreenSizeWatcher : MonoBehaviour |
| | 7 | | { |
| 0 | 8 | | private BaseVariable<Vector2Int> screenSize => DataStore.i.screen.size; |
| | 9 | | private void Awake() |
| | 10 | | { |
| 0 | 11 | | UpdateScreenSize(); |
| 0 | 12 | | } |
| | 13 | | private void LateUpdate() |
| | 14 | | { |
| 0 | 15 | | if (HasScreenSizeChanged()) |
| | 16 | | { |
| 0 | 17 | | UpdateScreenSize(); |
| | 18 | | } |
| 0 | 19 | | } |
| | 20 | |
|
| | 21 | | private void UpdateScreenSize() |
| | 22 | | { |
| 0 | 23 | | screenSize.Set(new Vector2Int(Screen.width, Screen.height)); |
| 0 | 24 | | } |
| | 25 | | private bool HasScreenSizeChanged() |
| | 26 | | { |
| 0 | 27 | | Vector2Int size = screenSize.Get(); |
| 0 | 28 | | return size.x != Screen.width || size.y != Screen.height; |
| | 29 | | } |
| | 30 | | } |
| | 31 | | } |