x


Child object of another GameObject invisible or inactive @ runtime

How do you disable the render or inactivity of the child object of another object?

more ▼

asked Dec 27 '10 at 10:07 AM

ina gravatar image

ina
3.3k 492 547 597

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You can set the active state of any GameObject and all of its children with SetActiveRecursively You can also find individual children by name like this and disable their renderer individually with

// make the object invisible
renderer.enabled = false;
more ▼

answered Dec 27 '10 at 10:17 AM

Sebas gravatar image

Sebas
4k 12 18 45

Beat me to it by 5 seconds, good job. You should also add that because it only searches in the GO's children it also has the benefit of not slowing everything down to a crawl like Find usually does.

Dec 27 '10 at 10:22 AM azzogat

... unless the game object has LOTS of children!

Dec 27 '10 at 06:15 PM ina

does setting an object to be inactive also removes its render?

Dec 27 '10 at 06:16 PM ina

The renderer itself is never removed unless you specifically remove the component. Deactivating a game object will result in the object not being rendered anymore.

Dec 28 '10 at 12:59 PM Sebas
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2074
x418
x407
x275
x112

asked: Dec 27 '10 at 10:07 AM

Seen: 2880 times

Last Updated: Dec 27 '10 at 10:07 AM