fix: Prevent switching to current report
This commit is contained in:
@@ -40,10 +40,11 @@ namespace Cryville.EEW.Unity.UI {
|
|||||||
|
|
||||||
if (_displayingReports.Count == 0) {
|
if (_displayingReports.Count == 0) {
|
||||||
m_currentView.gameObject.SetActive(false);
|
m_currentView.gameObject.SetActive(false);
|
||||||
|
_index = -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (_index > index) --_index;
|
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);
|
if (_displayingReports.Count <= 1) m_listView.gameObject.SetActive(false);
|
||||||
@@ -60,7 +61,7 @@ namespace Cryville.EEW.Unity.UI {
|
|||||||
m_currentView.gameObject.SetActive(false);
|
m_currentView.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _index;
|
int _index = -1;
|
||||||
float _tickDown;
|
float _tickDown;
|
||||||
void Update() {
|
void Update() {
|
||||||
if (_displayingReports.Count == 0) return;
|
if (_displayingReports.Count == 0) return;
|
||||||
@@ -69,8 +70,9 @@ namespace Cryville.EEW.Unity.UI {
|
|||||||
SwitchTo((_index + 1) % _displayingReports.Count);
|
SwitchTo((_index + 1) % _displayingReports.Count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SwitchTo(int index) {
|
void SwitchTo(int index, bool forced = false) {
|
||||||
if (_index < _displayingReports.Count)
|
if (!forced && _index == index) return;
|
||||||
|
if (_index < _displayingReports.Count && _index != -1)
|
||||||
_displayingViews[_index].SetCurrent(false);
|
_displayingViews[_index].SetCurrent(false);
|
||||||
_index = index;
|
_index = index;
|
||||||
var e = _displayingReports[index];
|
var e = _displayingReports[index];
|
||||||
|
Reference in New Issue
Block a user