- Home /
How to hide GUI and chilren?
Okay so maybe it's just me but I can not figure this out and google hasn't helped either.
I have a few scroll bars with different content each. They will have buttons, Images, text, sliders and whatever. I want an individual "Scroll View" and all of it's content/children to be hidden as well and unhide them when I need them. I don't want to disable it. I'm basically getting the Scroll Views and their content with...
Transform[] allChildren = GetComponentsInChildren<Transform>();
foreach (Transform child in allChildren)
{
//code that hides stuff
}
I did try looking in the editor at their components and then the "//code that hides suff" would be
if(child.getcomponent<whateverComponentItWas>() != null)// to check if actually had it so it didn't throw an error
{
child.getComponent<WhatverComponent>().enabled = false;
}
but I was thinking that there has got to be a better way to do this because its taking up resources getting every component of every child.
So how do I do this?
Why cant you just disable the parent of the children you want to hide?
I.e. put them all on the same game object and hide that.
Your answer
![](https://koobas.hobune.stream/wayback/20220612210420im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can you have a scrollview inside a textfield? 0 Answers
Distribute terrain in zones 3 Answers
GUI wont show in for loop 1 Answer
[4.6] Add scroll wheel functionality to scroll rect 2 Answers