Clear GameObject Component and Transform lists properly on close

This commit is contained in:
Sinai 2021-05-27 19:29:00 +10:00
parent 0b973393d1
commit 365269b0dd
3 changed files with 19 additions and 3 deletions

View File

@ -63,7 +63,7 @@ namespace UnityExplorer.UI.Inspectors
addCompInput.Text = "";
TransformTree.Clear();
ComponentList.Clear();
UpdateComponents();
}
public override void CloseInspector()
@ -112,6 +112,9 @@ namespace UnityExplorer.UI.Inspectors
private IEnumerable<GameObject> GetTransformEntries()
{
if (!GOTarget)
return Enumerable.Empty<GameObject>();
cachedChildren.Clear();
for (int i = 0; i < GOTarget.transform.childCount; i++)
cachedChildren.Add(GOTarget.transform.GetChild(i).gameObject);
@ -124,10 +127,21 @@ namespace UnityExplorer.UI.Inspectors
private readonly List<bool> behaviourEnabledStates = new List<bool>();
// ComponentList.GetRootEntriesMethod
private List<Component> GetComponentEntries() => componentEntries;
private List<Component> GetComponentEntries() => GOTarget ? componentEntries : Enumerable.Empty<Component>().ToList();
public void UpdateComponents()
{
if (!GOTarget)
{
componentEntries.Clear();
compInstanceIDs.Clear();
behaviourEntries.Clear();
behaviourEnabledStates.Clear();
ComponentList.RefreshData();
ComponentList.ScrollPool.Refresh(true, true);
return;
}
// Check if we actually need to refresh the component cells or not.
var comps = GOTarget.GetComponents<Component>();
var behaviours = GOTarget.GetComponents<Behaviour>();

View File

@ -21,7 +21,8 @@ namespace UnityExplorer.UI.Inspectors
public void Clear()
{
this.currentEntries.Clear();
RefreshData();
ScrollPool.Refresh(true, true);
}
private bool CheckShouldDisplay(Component _, string __) => true;

View File

@ -83,6 +83,7 @@ namespace UnityExplorer.UI.Widgets
displayIndex = 0;
autoExpandedIDs.Clear();
expandedInstanceIDs.Clear();
this.ScrollPool.Refresh(true, true);
}
public bool IsCellExpanded(int instanceID)