Commit f2a75051 authored by SherryChaos's avatar SherryChaos

Guard superScrollView calls

parent b27a335d
...@@ -16,7 +16,7 @@ namespace MDPro3.UI ...@@ -16,7 +16,7 @@ namespace MDPro3.UI
public SuperScrollView superScrollView; public SuperScrollView superScrollView;
private List<MyCardRoom> rooms; private List<MyCardRoom> rooms;
private List<string[]> tasks = new List<string[]>(); private readonly List<string[]> tasks = new();
private void OnEnable() private void OnEnable()
{ {
...@@ -96,7 +96,7 @@ namespace MDPro3.UI ...@@ -96,7 +96,7 @@ namespace MDPro3.UI
room.options.replay_mode.ToString() room.options.replay_mode.ToString()
}; };
tasks.Add(task); tasks.Add(task);
if (gameObject.activeInHierarchy) if (superScrollView != null && gameObject.activeInHierarchy)
superScrollView.Add(task); superScrollView.Add(task);
} }
public void UpdateRoom(MyCardRoom room) public void UpdateRoom(MyCardRoom room)
...@@ -129,7 +129,7 @@ namespace MDPro3.UI ...@@ -129,7 +129,7 @@ namespace MDPro3.UI
{ {
for (var j = 1; j < task.Length; j++) for (var j = 1; j < task.Length; j++)
tasks[i][j] = task[j]; tasks[i][j] = task[j];
if (gameObject.activeInHierarchy) if (superScrollView != null && gameObject.activeInHierarchy)
superScrollView.UpdateAt(i, task); superScrollView.UpdateAt(i, task);
break; break;
} }
...@@ -142,7 +142,7 @@ namespace MDPro3.UI ...@@ -142,7 +142,7 @@ namespace MDPro3.UI
if (rooms[i].id == roomId) if (rooms[i].id == roomId)
{ {
rooms.Remove(rooms[i]); rooms.Remove(rooms[i]);
if (gameObject.activeInHierarchy) if (superScrollView != null && gameObject.activeInHierarchy)
superScrollView.RemoveAt(i); superScrollView.RemoveAt(i);
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment