Hi everyone!
I started a new project, a tabletop-like card game. I made a card prefab based system with a script that updates the card visuals (name, costs, etc.) based on ScriptableObject data.
I also set up a “card slot” system: each slot is a RectTransform inside my Canvas (it’s the market area) to draw cards from the pile, but each time I instantiate a prefab to my card slot, it appears way offset. It should appear centered into my card slot.
I suspect this is related to the RectTransform (anchors / pivot / SetParent), but I’m a newbie with UI layout and I’m not sure what I’m doing wrong.
Here is a screenshot:
(screenshot of the scene, the cards you see on the bottom left should appear centered in the “MarketSlot” I have selected)
Code-wise, I’m doing something like this when spawning a card:
GameObject cardObj = Instantiate(cardPrefab);
cardObj.transform.SetParent(cardSlotTransform, false);
then I set cardObj’s CardDisplay data…
What is the correct way to set up RectTransforms (anchors/pivot) on the prefab and the slot so that the card appears centered in the slot when I instantiate it?
Any tips or best practices for UI card layouts are very welcome!
Thanks in advance, and sorry if my explanation isn’t super clear ![]()


