Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by mwinteringham · Feb 24, 2013 at 11:20 PM · gameobjectparentchildscriptingbasicssetactive

Can a parent SetActive a child GameObject anymore

Hi all,

I am getting seriously frustrated with a simple feature of having two GameObjects that have a script with two functions that can be called that will turn on or off their respective child GameObject. Can this be done due to the changes in 4.0?

I have tried all sorts of different ways of getting access to the Child object and using SetActive but nothing works. The child GameObject never enables and sometimes it only enables in the Hierarchy and not in Scene!

Help! What am I doing wrong?

Thanks, Mark

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Owen-Reynolds · Feb 25, 2013 at 01:53 AM 0
Share

Are the parents inActive? The old rules allowed active children with inactive parents, the new ones don't.

2 Replies

· Add your reply
  • Sort: 
avatar image
7
Best Answer

Answer by Mikilo · Feb 24, 2013 at 11:35 PM

Hello,

This may helps you:

 for (int i = 0; i < this.transform.GetChildCount(); ++i)
 {
     this.transform.GetChild(i).gameObject.SetActive(true);
 }

Didn't try the code above, but it should do what you asked.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image inewland · Nov 15, 2013 at 05:51 PM 0
Share

Don't forget to leave your children active! When you disable the parent, all children are automatically 'disabled'... or rather not active and visible.

avatar image Dreaming · Apr 23, 2014 at 12:04 PM 0
Share

Thank for you!

avatar image
0

Answer by mwinteringham · Feb 25, 2013 at 02:28 PM

Turns out I was referencing the Prefab rather than the Instantiated object which was causing all the problems.

The above code however works a treat so happy to mark this as the Answer. Thanks for the help.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Mikilo · Feb 25, 2013 at 02:31 PM 0
Share

Glad that code helps you. =D

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Make a simple tree 1 Answer

How to check parent value instead name value(more details in post) 3 Answers

Display Name Above Object 2 Answers

All encompassing Game Object. 1 Answer

how do I get reference to a parent or a child? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges