Fix TransformCell for destroyed transforms

This commit is contained in:
Sinai 2021-04-22 22:57:04 +10:00
parent feb86a77fd
commit eb58ab5327

View File

@ -48,8 +48,11 @@ namespace UnityExplorer.UI.Widgets
//This is called from the SetCell method in DataSource //This is called from the SetCell method in DataSource
public void ConfigureCell(CachedTransform cached, int cellIndex) public void ConfigureCell(CachedTransform cached, int cellIndex)
{ {
if (cached == null || !cached.Value) if (cached == null)
{
ExplorerCore.LogWarning("Setting TransformTree cell but the CachedTransform is null!");
return; return;
}
if (!Enabled) if (!Enabled)
Enable(); Enable();
@ -59,25 +62,31 @@ namespace UnityExplorer.UI.Widgets
spacer.minWidth = cached.Depth * 15; spacer.minWidth = cached.Depth * 15;
nameLabel.text = cached.Value.name; if (cached.Value)
nameLabel.color = cached.Value.gameObject.activeSelf ? Color.white : Color.grey;
int childCount = cached.Value.childCount;
if (childCount > 0)
{ {
nameLabel.text = $"<color=grey>[{childCount}]</color> {nameLabel.text}"; nameLabel.text = cached.Value.name;
nameLabel.color = cached.Value.gameObject.activeSelf ? Color.white : Color.grey;
expandButton.interactable = true; int childCount = cached.Value.childCount;
//expandLabel.enabled = true; if (childCount > 0)
expandLabel.text = cached.Expanded ? "▼" : "►"; {
expandLabel.color = cached.Expanded ? new Color(0.5f, 0.5f, 0.5f) : new Color(0.3f, 0.3f, 0.3f); nameLabel.text = $"<color=grey>[{childCount}]</color> {nameLabel.text}";
expandButton.interactable = true;
expandLabel.text = cached.Expanded ? "▼" : "►";
expandLabel.color = cached.Expanded ? new Color(0.5f, 0.5f, 0.5f) : new Color(0.3f, 0.3f, 0.3f);
}
else
{
expandButton.interactable = false;
expandLabel.text = "▪";
expandLabel.color = new Color(0.3f, 0.3f, 0.3f);
}
} }
else else
{ {
expandButton.interactable = false; nameLabel.text = $"[Destroyed]";
expandLabel.text = "▪"; nameLabel.color = Color.red;
expandLabel.color = new Color(0.3f, 0.3f, 0.3f);
//expandLabel.enabled = false;
} }
} }