From cc57334ab23345386303d27cded643b7ad499e9a Mon Sep 17 00:00:00 2001 From: PopSlime Date: Sun, 16 Feb 2025 13:56:20 +0800 Subject: [PATCH] fix: Prevent switching to current report --- Assets/Cryville.EEW.Unity/UI/EventOngoingListView.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Assets/Cryville.EEW.Unity/UI/EventOngoingListView.cs b/Assets/Cryville.EEW.Unity/UI/EventOngoingListView.cs index 4e623ae..86e7d70 100644 --- a/Assets/Cryville.EEW.Unity/UI/EventOngoingListView.cs +++ b/Assets/Cryville.EEW.Unity/UI/EventOngoingListView.cs @@ -40,10 +40,11 @@ namespace Cryville.EEW.Unity.UI { if (_displayingReports.Count == 0) { m_currentView.gameObject.SetActive(false); + _index = -1; } else { if (_index > index) --_index; - else if (_index == index) SwitchTo(index % _displayingReports.Count); + else if (_index == index) SwitchTo(index % _displayingReports.Count, true); } if (_displayingReports.Count <= 1) m_listView.gameObject.SetActive(false); @@ -60,7 +61,7 @@ namespace Cryville.EEW.Unity.UI { m_currentView.gameObject.SetActive(false); } - int _index; + int _index = -1; float _tickDown; void Update() { if (_displayingReports.Count == 0) return; @@ -69,8 +70,9 @@ namespace Cryville.EEW.Unity.UI { SwitchTo((_index + 1) % _displayingReports.Count); } } - void SwitchTo(int index) { - if (_index < _displayingReports.Count) + void SwitchTo(int index, bool forced = false) { + if (!forced && _index == index) return; + if (_index < _displayingReports.Count && _index != -1) _displayingViews[_index].SetCurrent(false); _index = index; var e = _displayingReports[index];