From fd130f9538995c35c658cf1ef445693a0eb36975 Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Tue, 19 Nov 2024 23:15:35 +0100 Subject: [PATCH] Fix width calculation bug --- Assets/Scripts/EndpointLoader.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/EndpointLoader.cs b/Assets/Scripts/EndpointLoader.cs index 7442053..91e58c7 100644 --- a/Assets/Scripts/EndpointLoader.cs +++ b/Assets/Scripts/EndpointLoader.cs @@ -70,14 +70,15 @@ namespace WebViewStream { Transform cameraTransform = Camera.main.transform; Vector3 localOffset = new Vector3(-0.3f, 0.1f, 1.5f); + int count = instantiatedItems.Count; - if (instantiatedItems.Count == 0) + if (count == 0) { return cameraTransform.position + cameraTransform.TransformDirection(localOffset); } - GameObject lastItem = instantiatedItems[instantiatedItems.Count - 1]; - localOffset = new Vector3(localOffset.x + GetItemWidth(lastItem), localOffset.y, localOffset.z); + GameObject lastItem = instantiatedItems[count - 1]; + localOffset = new Vector3(localOffset.x + GetItemWidth(lastItem) * count, localOffset.y, localOffset.z); return cameraTransform.position + cameraTransform.TransformDirection(localOffset); }