From 220d651cfb071398a609f3ea8daaa14fb86a89ec Mon Sep 17 00:00:00 2001 From: Savya Bikram Shah Date: Fri, 5 Jun 2026 18:33:39 +0545 Subject: [PATCH] Tutorial fix --- .../Code/Features/Tutorial/Systems/TutorialDirector.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Assets/Darkmatter/Code/Features/Tutorial/Systems/TutorialDirector.cs b/Assets/Darkmatter/Code/Features/Tutorial/Systems/TutorialDirector.cs index af4a564..df17570 100644 --- a/Assets/Darkmatter/Code/Features/Tutorial/Systems/TutorialDirector.cs +++ b/Assets/Darkmatter/Code/Features/Tutorial/Systems/TutorialDirector.cs @@ -313,13 +313,16 @@ namespace Darkmatter.Features.Tutorial.Systems private static (RectTransform piece, RectTransform slot) FindFirstPieceAndSlot() { + // Pieces spawn in data order under one SpawnRoot, so sibling 0 is the top of the tray. + // FindObjectsByType returns undefined order — pick the lowest sibling index, not [0]. var pieces = UnityEngine.Object.FindObjectsByType(FindObjectsSortMode.None); ShapePiece piece = null; + var bestIndex = int.MaxValue; foreach (var p in pieces) { if (p == null || p.IsLocked || !p.gameObject.activeInHierarchy) continue; - piece = p; - break; + var index = p.transform.GetSiblingIndex(); + if (index < bestIndex) { bestIndex = index; piece = p; } } if (piece == null) return (null, null);