- Home /
How to show only a single child on a panel
So I'm new to Unity struggling with something with a simple 2D card game I'm trying to create. What I want to do is have a discard pile where you can send cards, and it'll only have the top card visible at a time.
I have a panel, and I'm successfully sending cards to the panel as children. However, I can't figure out how to show just ONE of them. I've tried experimenting with Layout Groups, but Horizontal and Vertical Layout Groups just show all the cards, even if I set the alpha on the cards to make them invisible.
How can I make it so only the top card is visible?
Answer by Casiell · Aug 29, 2018 at 05:35 PM
Are you using UI Images? If so, then the bottom card in your hierarchy will be visible. You can do: lastCard.transform.SetAsLastSibling after you child it to whatever object you want.
Your answer
![](https://koobas.hobune.stream/wayback/20220612173725im_/https://answers.unity.com/themes/thub/images/avi.jpg)