diff --git a/Assets/VoxelEditor/GUI/EntityReferencePropertyManager.cs b/Assets/VoxelEditor/GUI/EntityReferencePropertyManager.cs index 26eceb41..3a1d38e2 100644 --- a/Assets/VoxelEditor/GUI/EntityReferencePropertyManager.cs +++ b/Assets/VoxelEditor/GUI/EntityReferencePropertyManager.cs @@ -9,16 +9,22 @@ public class EntityReferenceLine : MonoBehaviour public int i; public Entity sourceEntity; public Entity targetEntity; + private LineRenderer line; void Start() { if (sourceEntity == null || targetEntity == null) return; Color color = ColorI(i); - LineRenderer line = gameObject.AddComponent(); + line = gameObject.AddComponent(); line.startWidth = line.endWidth = 0.1f; line.material = _lineMaterial; line.startColor = line.endColor = color; + UpdatePositions(); + } + + public void UpdatePositions() + { line.SetPosition(0, sourceEntity.PositionInEditor()); line.SetPosition(1, targetEntity.PositionInEditor()); } @@ -186,6 +192,11 @@ void Update() } return; // wait a frame to let the new/deleted objects update } + else + { + foreach (Transform child in transform) + child.GetComponent().UpdatePositions(); + } if (currentEntity != null) EntityPreviewManager.UpdateEntityPosition(currentEntity);