Tutorial fix

This commit is contained in:
Savya Bikram Shah
2026-06-05 18:33:39 +05:45
parent e27d0e54cb
commit 220d651cfb

View File

@@ -313,13 +313,16 @@ namespace Darkmatter.Features.Tutorial.Systems
private static (RectTransform piece, RectTransform slot) FindFirstPieceAndSlot() 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<ShapePiece>(FindObjectsSortMode.None); var pieces = UnityEngine.Object.FindObjectsByType<ShapePiece>(FindObjectsSortMode.None);
ShapePiece piece = null; ShapePiece piece = null;
var bestIndex = int.MaxValue;
foreach (var p in pieces) foreach (var p in pieces)
{ {
if (p == null || p.IsLocked || !p.gameObject.activeInHierarchy) continue; if (p == null || p.IsLocked || !p.gameObject.activeInHierarchy) continue;
piece = p; var index = p.transform.GetSiblingIndex();
break; if (index < bestIndex) { bestIndex = index; piece = p; }
} }
if (piece == null) return (null, null); if (piece == null) return (null, null);