Add null check for some UI components.

This commit is contained in:
2023-11-10 14:50:15 +08:00
parent a19a3d9b81
commit adf5019e2a
2 changed files with 6 additions and 4 deletions

View File

@@ -15,7 +15,9 @@ namespace Cryville.Crtr {
static Color _tickColor2 = new Color(1, 1, 1, .8f);
static Color _suspendedColor = new Color(1, 0, 0, 1);
void Update() {
switch (Game.NetworkTaskWorker.TickBackgroundTasks()) {
var status = Game.NetworkTaskWorker.TickBackgroundTasks();
if (_image == null) return;
switch (status) {
case WorkerStatus.Idle:
_image.color = _idleColor;
timer = 0f;

View File

@@ -42,7 +42,7 @@ namespace Cryville.Crtr.UI {
frameIndex--;
return;
}
m_progressBar.value = totalTasks == 0 ? 1 : (1 - (float)taskCount / totalTasks);
if (m_progressBar != null) m_progressBar.value = totalTasks == 0 ? 1 : (1 - (float)taskCount / totalTasks);
if (taskCount == 0) {
initialized = true;
// TODO Show main
@@ -62,7 +62,7 @@ namespace Cryville.Crtr.UI {
readonly Stack<string> _uiStack = new Stack<string>();
public void PushTitle(string title) {
_uiStack.Push(title);
m_title.SetText(title);
if (m_title) m_title.SetText(title);
}
public void Back() {
foreach (var obj in m_backBlockingObjects) {
@@ -71,7 +71,7 @@ namespace Cryville.Crtr.UI {
if (m_browserMaster.Back()) return;
if (_uiStack.Count <= 1) return;
_uiStack.Pop();
m_title.SetText(_uiStack.Peek());
if (m_title) m_title.SetText(_uiStack.Peek());
}
public void Quit() {
Application.Quit();