diff --git a/BeatSaberMarkupLanguage/Components/CustomListTableData.cs b/BeatSaberMarkupLanguage/Components/CustomListTableData.cs index 0402c104..ac142822 100644 --- a/BeatSaberMarkupLanguage/Components/CustomListTableData.cs +++ b/BeatSaberMarkupLanguage/Components/CustomListTableData.cs @@ -15,9 +15,9 @@ public class CustomListTableData : MonoBehaviour, TableView.IDataSource public bool expandCell = false; - private LevelListTableCell songListTableCellInstance; - private LevelPackCell levelPackTableCellInstance; - private SimpleTextTableCell simpleTextTableCellInstance; + private LevelListTableCell songListTableCellPrefab; + private LevelPackCell levelPackTableCellPrefab; + private SimpleTextTableCell simpleTextTableCellPrefab; private ListStyle listStyle = ListStyle.List; public enum ListStyle @@ -57,12 +57,12 @@ public LevelListTableCell GetTableCell() LevelListTableCell tableCell = (LevelListTableCell)tableView.DequeueReusableCellForIdentifier(reuseIdentifier); if (!tableCell) { - if (songListTableCellInstance == null) + if (songListTableCellPrefab == null) { - songListTableCellInstance = Resources.FindObjectsOfTypeAll().Where(x => x.name == "LevelListTableCell").First(); + songListTableCellPrefab = BeatSaberUI.DiContainer.Resolve().GetComponentInChildren()._levelCellPrefab; } - tableCell = Instantiate(songListTableCellInstance); + tableCell = Instantiate(songListTableCellPrefab); } tableCell._notOwned = false; @@ -76,12 +76,12 @@ public BSMLBoxTableCell GetBoxTableCell() BSMLBoxTableCell tableCell = (BSMLBoxTableCell)tableView.DequeueReusableCellForIdentifier(reuseIdentifier); if (!tableCell) { - if (levelPackTableCellInstance == null) + if (levelPackTableCellPrefab == null) { - levelPackTableCellInstance = Resources.FindObjectsOfTypeAll().Where(x => x.name == "AnnotatedBeatmapLevelCollectionCell").First(); + levelPackTableCellPrefab = BeatSaberUI.DiContainer.Resolve().GetComponentInChildren()._cellPrefab; } - tableCell = InstantiateBoxTableCell(levelPackTableCellInstance); + tableCell = InstantiateBoxTableCell(levelPackTableCellPrefab); } tableCell.name = nameof(BSMLBoxTableCell); @@ -118,12 +118,12 @@ public SimpleTextTableCell GetSimpleTextTableCell() SimpleTextTableCell tableCell = (SimpleTextTableCell)tableView.DequeueReusableCellForIdentifier(reuseIdentifier); if (!tableCell) { - if (simpleTextTableCellInstance == null) + if (simpleTextTableCellPrefab == null) { - simpleTextTableCellInstance = Resources.FindObjectsOfTypeAll().Where(x => x.name == "SimpleTextTableCell").First(); + simpleTextTableCellPrefab = BeatSaberUI.DiContainer.Resolve().GetComponentInChildren()._cellPrefab; } - tableCell = Instantiate(simpleTextTableCellInstance); + tableCell = Instantiate(simpleTextTableCellPrefab); } tableCell.name = $"BSML{nameof(SimpleTextTableCell)}"; @@ -184,13 +184,6 @@ public int NumberOfCells() return data.Count(); } - private void OnDestroy() - { - Destroy(songListTableCellInstance); - Destroy(levelPackTableCellInstance); - Destroy(simpleTextTableCellInstance); - } - public class CustomCellInfo { public string text;