| | 1 | | using UnityEngine; |
| | 2 | | using UnityEngine.UI; |
| | 3 | |
|
| | 4 | | internal class PreviewMenuView : MonoBehaviour |
| | 5 | | { |
| | 6 | | [SerializeField] internal Button menuButton; |
| | 7 | | [SerializeField] internal GameObject contentContainer; |
| | 8 | | [SerializeField] internal Transform menuList; |
| | 9 | |
|
| | 10 | | private bool isDestroyed; |
| | 11 | |
|
| | 12 | | private void Awake() |
| | 13 | | { |
| 7 | 14 | | menuButton.onClick.AddListener(() => |
| | 15 | | { |
| 2 | 16 | | SetVisible(!contentContainer.activeSelf); |
| 2 | 17 | | }); |
| 7 | 18 | | } |
| | 19 | |
|
| | 20 | | private void OnDestroy() |
| | 21 | | { |
| 7 | 22 | | isDestroyed = true; |
| 7 | 23 | | } |
| | 24 | |
|
| | 25 | | public void Dispose() |
| | 26 | | { |
| 5 | 27 | | if (!isDestroyed) |
| | 28 | | { |
| 5 | 29 | | Destroy(gameObject); |
| | 30 | | } |
| 5 | 31 | | } |
| | 32 | |
|
| | 33 | | public void AddMenuItem(Transform item) |
| | 34 | | { |
| 16 | 35 | | item.SetParent(menuList); |
| 16 | 36 | | item.localScale = Vector3.one; |
| 16 | 37 | | } |
| | 38 | |
|
| | 39 | | public void SetVisible(bool on) |
| | 40 | | { |
| 7 | 41 | | contentContainer.SetActive(on); |
| 7 | 42 | | } |
| | 43 | | } |