Skip to content

Commit

Permalink
Fix not clearing highlights when deselect multiple entities
Browse files Browse the repository at this point in the history
  • Loading branch information
vanjac committed Jul 20, 2024
1 parent 8f43620 commit 5b22c8a
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions Assets/VoxelEditor/GUI/EntityReferencePropertyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void UpdatePositions() {
}


private static bool updateTargets = false;
private static Entity currentEntity;
private static List<Entity> targetEntities = new List<Entity>();
private static HashSet<Entity> entitiesToClear = new HashSet<Entity>();
Expand Down Expand Up @@ -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) {
Expand All @@ -139,7 +139,6 @@ void Update() {
}

if (updateTargets) {
updateTargets = false;
foreach (Transform child in transform) {
Destroy(child.gameObject);
}
Expand All @@ -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<EntityReferenceLine>().UpdatePositions();
}
Expand Down

0 comments on commit 5b22c8a

Please sign in to comment.