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
0
Question by paulsz · Oct 08, 2012 at 01:59 PM · gameobjectsetactiveunity4

Unity 4 gameObject.active equivalent

The new Unity 4 made some significant changes in how gameObject activation works.

I wanted to know how should we use the new method SetActive and the getters activeSelf and activeInHierarchy to replicate the same behaviour with the old gameObject.active and gameObject.SetActiveRecursively;

example 1:

in the old days we could do this:

`gameObject.SetActiveRecursively(false); gameObject.transform.parent = null;`

Now, we cannot do this as it states that we cannot change the parent of an object and modify its state (active/inactive) in the same frame + the exception "GameObject is already being activated or deactivated."

example 2:

in the old unity I could do this:

`gameObject.SetActiveRecursively(false); gameObject.active = true`

this would keep the children deactivated while the parent is active. Now it seems we cannot do this anymore since all the children reflect the state of the parent as I understood.

Can someone please clarify this for me and say if there is a way to implement the old behaviour with the new gameObject activation philosophy ? Or the only thing left to do is to change everything in the scene and code and adapt to the new changes ?

Comment
Add comment
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

2 Replies

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

Answer by Griffo · Oct 08, 2012 at 02:37 PM

http://answers.unity3d.com/questions/324130/unity4-active-replacement.html

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 paulsz · Oct 08, 2012 at 02:44 PM 0
Share

So basically, there is no workaround to keep the same structure and code from the pre Unity 4. We just have to change and adapt the structure of the game objects in the scene and the code to adapt to the new game activation strategy. Now I can start modifying without worrying that there is an easier way :)

avatar image Griffo · Oct 08, 2012 at 02:46 PM 0
Share

Looks that way ..

avatar image
0

Answer by Griffo · Oct 08, 2012 at 02:10 PM

 gameObject.SetActive(true);
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 paulsz · Oct 08, 2012 at 02:23 PM 0
Share

Thanks for the quick reply but that doesn't really help. I know that SetActive(true) is the new SetActiveRecurisively(true). The problem arises with the old use of gameObject.active which has no equivalent instruction in Unity 4.

avatar image paulsz · Oct 08, 2012 at 02:23 PM 1
Share

Plus the fact that you cannot change the parent in the same frame the object is being activated/deactivated

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

10 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

Related Questions

SetActive not reactivating with Tags 2 Answers

Unity 4 SetActive - SetActiveRecursively parent-child trouble 2 Answers

Scriptural Child Implementation 2 Answers

Is it possible to determine if OnDisable() is being called from parent.SetActive( false ) or self? 2 Answers

How to activate all inactive objects? 1 Answer


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