CodePuppe
CodePuppe

Reputation: 119

Hide Child Objects Together with the Parent

I've got a little problem. On a button press I need to open a panel with settings in animation. The thing is when I reduce width and height of a parent object (panel) it does not hide the child objects whatsoever. How can I make the parent object to influence the children's height and width when I change them in the parent?

Upvotes: 1

Views: 428

Answers (2)

omer dogan
omer dogan

Reputation: 11

If you want to scale your child objects with your parent canvas, you should set your render mode -> world space in your parent object.

Upvotes: 0

Matthew Loveday
Matthew Loveday

Reputation: 506

If these objects are UI elements you can use add a Mask to the panel to hide any child objects that go outside of the area of the panel. As you can see below the square which is a child of the panel object does not render anything outside of the area of the panel.

enter image description here

If you want the UI elements to scale with the changing size of the panel then you should use anchors which will mean that the children of the panel will "anchor" themselves to the positions you set. Here's a short gif to illustrate how it works.

enter image description here

That's with the child image set to preserve it's aspect ratio, if you disable that setting then the box will stretch to perfectly fit the anchors.

Upvotes: 2

Related Questions