Fix width calculation bug

This commit is contained in:
Santiago Lo Coco 2024-11-19 23:15:35 +01:00
parent a57cb87be5
commit fd130f9538
1 changed files with 4 additions and 3 deletions

View File

@ -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);
}