fix: Prevent switching to current report
This commit is contained in:
@@ -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];
|
||||
|
Reference in New Issue
Block a user