diff --git a/src/UI/Inspectors/GameObjectInspector.cs b/src/UI/Inspectors/GameObjectInspector.cs index 07ba961..54b6b8e 100644 --- a/src/UI/Inspectors/GameObjectInspector.cs +++ b/src/UI/Inspectors/GameObjectInspector.cs @@ -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 GetTransformEntries() { + if (!GOTarget) + return Enumerable.Empty(); + 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 behaviourEnabledStates = new List(); // ComponentList.GetRootEntriesMethod - private List GetComponentEntries() => componentEntries; + private List GetComponentEntries() => GOTarget ? componentEntries : Enumerable.Empty().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(); var behaviours = GOTarget.GetComponents(); diff --git a/src/UI/Inspectors/GameObjectWidgets/ComponentList.cs b/src/UI/Inspectors/GameObjectWidgets/ComponentList.cs index 5f4338e..538e503 100644 --- a/src/UI/Inspectors/GameObjectWidgets/ComponentList.cs +++ b/src/UI/Inspectors/GameObjectWidgets/ComponentList.cs @@ -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; diff --git a/src/UI/Widgets/TransformTree/TransformTree.cs b/src/UI/Widgets/TransformTree/TransformTree.cs index e5a938f..c5050a2 100644 --- a/src/UI/Widgets/TransformTree/TransformTree.cs +++ b/src/UI/Widgets/TransformTree/TransformTree.cs @@ -83,6 +83,7 @@ namespace UnityExplorer.UI.Widgets displayIndex = 0; autoExpandedIDs.Clear(); expandedInstanceIDs.Clear(); + this.ScrollPool.Refresh(true, true); } public bool IsCellExpanded(int instanceID)