Code cleanup.

This commit is contained in:
2023-11-10 14:32:28 +08:00
parent b56722b2d1
commit b48bd7b8ba

View File

@@ -134,9 +134,13 @@ namespace Cryville.Common.Unity.UI {
private void OnFrameUpdate() {
if (!initialized) return;
if (lines != null) for (int i = 0; i < lines.Length; i++)
if (lines[i] != null) foreach (GameObject c in lines[i])
GameObject.Destroy(c);
if (lines != null) {
for (int i = 0; i < lines.Length; i++) {
if (lines[i] != null) {
foreach (GameObject c in lines[i]) Destroy(c);
}
}
}
lines = new GameObject[VisibleLines][];
refl = new int[VisibleLines];
for (int i = 0; i < refl.Length; i++) refl[i] = i;
@@ -153,8 +157,9 @@ namespace Cryville.Common.Unity.UI {
private void ResetLines() {
for (int i = 0; i < lines.Length; i++) {
if (lines[i] != null) foreach (GameObject c in lines[i])
GameObject.Destroy(c);
if (lines[i] != null) {
foreach (GameObject c in lines[i]) Destroy(c);
}
lines[i] = new GameObject[LineItemCount];
GenerateLine(i, refl[i]);
}
@@ -200,7 +205,7 @@ namespace Cryville.Common.Unity.UI {
void GenerateLine(int index, int line) {
for (int j = 0; j < LineItemCount; j++) {
var child = GameObject.Instantiate(m_itemTemplate, transform, false);
var child = Instantiate(m_itemTemplate, transform, false);
lines[index][j] = child;
}
LoadLine(index, line);