From 5b22c8a6cdee304425f20cdebfffd48ad832b964 Mon Sep 17 00:00:00 2001 From: j v Date: Sat, 20 Jul 2024 01:00:04 -0700 Subject: [PATCH] Fix not clearing highlights when deselect multiple entities --- .../GUI/EntityReferencePropertyManager.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Assets/VoxelEditor/GUI/EntityReferencePropertyManager.cs b/Assets/VoxelEditor/GUI/EntityReferencePropertyManager.cs index b3a91a82..c2897d9e 100644 --- a/Assets/VoxelEditor/GUI/EntityReferencePropertyManager.cs +++ b/Assets/VoxelEditor/GUI/EntityReferencePropertyManager.cs @@ -27,7 +27,6 @@ public void UpdatePositions() { } - private static bool updateTargets = false; private static Entity currentEntity; private static List targetEntities = new List(); private static HashSet entitiesToClear = new HashSet(); @@ -121,12 +120,13 @@ void OnDestroy() { } void Update() { - if (currentEntity == null && targetEntities.Count != 0) { - targetEntities.Clear(); - currentTargetEntityI = -1; - } - - if (transform.childCount != targetEntities.Count) { + bool updateTargets = false; + if (currentEntity == null && transform.childCount != 0) { + foreach (Transform child in transform) { + Destroy(child.gameObject); + } + return; // no lines for multiple selection + } else if (transform.childCount != targetEntities.Count) { updateTargets = true; } else { foreach (Transform child in transform) { @@ -139,7 +139,6 @@ void Update() { } if (updateTargets) { - updateTargets = false; foreach (Transform child in transform) { Destroy(child.gameObject); } @@ -151,8 +150,7 @@ void Update() { line.sourceEntity = currentEntity; line.targetEntity = targetEntities[i]; } - return; // wait a frame to let the new/deleted objects update - } else { + } else if (currentEntity != null) { foreach (Transform child in transform) { child.GetComponent().UpdatePositions(); }