Skip to content

Commit f39cda0

Browse files
committed
Address the u-pr feedback
1 parent 2ecae32 commit f39cda0

2 files changed

Lines changed: 29 additions & 6 deletions

File tree

Assets/QA/Tests/Core Platform Menu/ReturnToMenuOverlay.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Collections;
12
using System.Collections.Generic;
23
using TMPro;
34
using UnityEngine;
@@ -151,12 +152,19 @@ void SetPanelVisible(bool visible)
151152
if (m_ConfirmPanel != null)
152153
m_ConfirmPanel.SetActive(visible);
153154

154-
if (visible && m_ReturnButton != null && EventSystem.current != null)
155-
EventSystem.current.SetSelectedGameObject(m_ReturnButton);
155+
if (visible && m_ReturnButton != null)
156+
StartCoroutine(SelectNextFrame(m_ReturnButton));
156157
else if (!visible && EventSystem.current != null)
157158
EventSystem.current.SetSelectedGameObject(null);
158159
}
159160

161+
IEnumerator SelectNextFrame(GameObject target)
162+
{
163+
yield return null;
164+
if (EventSystem.current != null)
165+
EventSystem.current.SetSelectedGameObject(target);
166+
}
167+
160168
// ── Scene suspend / resume ──────────────────────────────────
161169

162170
void SuspendActiveScene()

Assets/QA/Tests/Core Platform Menu/SceneMenu.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ struct CategoryUI
6060
readonly List<SceneEntry> m_Scenes = new List<SceneEntry>();
6161
readonly Dictionary<string, CategoryUI> m_Categories = new Dictionary<string, CategoryUI>();
6262
readonly Dictionary<int, GameObject> m_Buttons = new Dictionary<int, GameObject>();
63+
readonly HashSet<GameObject> m_ButtonSet = new HashSet<GameObject>();
6364
Canvas m_Canvas;
6465
Sprite m_RoundSprite;
6566
TextMeshProUGUI m_Badge;
@@ -86,12 +87,22 @@ void Awake()
8687
EventSystem.current.SetSelectedGameObject(m_FirstButton);
8788
}
8889

90+
void OnDestroy()
91+
{
92+
if (m_RoundSprite != null)
93+
{
94+
if (m_RoundSprite.texture != null)
95+
Destroy(m_RoundSprite.texture);
96+
Destroy(m_RoundSprite);
97+
}
98+
}
99+
89100
void LateUpdate()
90101
{
91102
if (m_ScrollRect == null || EventSystem.current == null) return;
92103

93104
var selected = EventSystem.current.currentSelectedGameObject;
94-
if (selected == null || !m_Buttons.ContainsValue(selected)) return;
105+
if (selected == null || !m_ButtonSet.Contains(selected)) return;
95106

96107
var selectedRT = selected.GetComponent<RectTransform>();
97108
var contentRT = m_ScrollRect.content;
@@ -109,12 +120,12 @@ void LateUpdate()
109120
if (selWorldBottom < vpWorldBottom)
110121
{
111122
float delta = vpWorldBottom - selWorldBottom + 10f;
112-
contentRT.anchoredPosition += new Vector2(0, -delta / m_ScrollRect.transform.lossyScale.y);
123+
contentRT.anchoredPosition += new Vector2(0, delta / m_ScrollRect.transform.lossyScale.y);
113124
}
114125
else if (selWorldTop > vpWorldTop)
115126
{
116127
float delta = selWorldTop - vpWorldTop + 10f;
117-
contentRT.anchoredPosition += new Vector2(0, delta / m_ScrollRect.transform.lossyScale.y);
128+
contentRT.anchoredPosition += new Vector2(0, -delta / m_ScrollRect.transform.lossyScale.y);
118129
}
119130
}
120131

@@ -146,8 +157,11 @@ static void SetupEventSystem()
146157
{
147158
hasSceneES = true;
148159
}
149-
else
160+
else if (es.gameObject.name == "[OverlayEventSystem]")
150161
{
162+
// Clean up the ReturnToMenuOverlay's DDOL EventSystem that may
163+
// linger after returning to the menu. Other persistent
164+
// EventSystems (e.g. from a global manager) are left alone.
151165
es.gameObject.SetActive(false);
152166
Destroy(es.gameObject);
153167
}
@@ -618,6 +632,7 @@ void BuildSceneButton(Transform parent, SceneEntry entry)
618632
}
619633

620634
m_Buttons[entry.buildIndex] = go;
635+
m_ButtonSet.Add(go);
621636
}
622637

623638
#endregion

0 commit comments

Comments
 (0)