Skip to content

Commit e89a4b8

Browse files
committed
Fix OnBugReportWindowShown callbacks
1 parent da66128 commit e89a4b8

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

Runtime/Scripts/BugReportUI.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ public class BugReportUI : MonoBehaviour
105105
// we keep track of the issues to not record the video when any of the issues are being uploaded
106106
private List<Issue> _issues = new List<Issue>();
107107

108+
private bool _uiWasVisible = false;
109+
108110
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
109111
private static void InitializeLogger()
110112
{
@@ -211,13 +213,23 @@ void Update()
211213
}
212214
}
213215

214-
if (BugReportPanel.activeSelf && !_cursorStateChanged)
216+
if (UiIsVisible())
215217
{
216-
ModifyCursorState();
218+
if (!_uiWasVisible)
219+
{
220+
OnBugReportWindowShown?.Invoke();
221+
ModifyCursorState();
222+
}
223+
_uiWasVisible = true;
217224
}
218-
else if (!BugReportPanel.activeSelf && !MessagePanelUI.gameObject.activeSelf && _cursorStateChanged)
225+
else if (!UiIsVisible())
219226
{
220-
RestoreCursorState();
227+
if (_uiWasVisible)
228+
{
229+
OnBugReportWindowHidden?.Invoke();
230+
RestoreCursorState();
231+
}
232+
_uiWasVisible = false;
221233
}
222234

223235
#if !ENABLE_INPUT_SYSTEM
@@ -231,7 +243,12 @@ void Update()
231243
private bool SholdBeRecordingVideo()
232244
{
233245
// if true, the report is being uploaded, some processes should be paused
234-
return IncludeVideo && !BugReportPanel.activeSelf && !_issues.Exists(issue => !issue.IsMediaUploadComplete);
246+
return IncludeVideo && !UiIsVisible() && !_issues.Exists(issue => !issue.IsMediaUploadComplete);
247+
}
248+
249+
private bool UiIsVisible()
250+
{
251+
return BugReportPanel.activeSelf || MessagePanelUI.gameObject.activeSelf || ReportSubmittedUI.gameObject.activeSelf;
235252
}
236253

237254
private void ModifyCursorState()
@@ -242,7 +259,6 @@ private void ModifyCursorState()
242259
_previousCursorLockMode = Cursor.lockState;
243260
Cursor.lockState = CursorLockMode.None;
244261
Cursor.visible = true;
245-
OnBugReportWindowShown?.Invoke();
246262
}
247263
}
248264

@@ -253,7 +269,6 @@ private void RestoreCursorState()
253269
Cursor.lockState = _previousCursorLockMode;
254270
Cursor.visible = false;
255271
_cursorStateChanged = false;
256-
OnBugReportWindowHidden?.Invoke();
257272
}
258273
}
259274

0 commit comments

Comments
 (0)