Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
1
Question by TwistedDevelopments · Jul 28, 2021 at 05:58 PM · setactive

GameObject automatically setting itself to disabled on entering play mode

I have a GameObject which is automatically disabling itself when I enter play mode.

There is nothing, anywhere, in my code that sets the object as disabled to begin with so I shouldn't need to be setting it active. I haven't unchecked the object in the Inspector window and I've tried to force the object to be active by making a variable to store the GameObject and theVar.SetActive(true); in the Awake function, this didn't help. I've also tried this.SetActive(true);

Can anyone help me out?

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

3 Replies

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

Answer by TwistedDevelopments · Jul 28, 2021 at 07:52 PM

I updated Unity and it fixed whatever was wrong.

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 d2clon · Jul 28, 2021 at 08:54 PM 0
Share

I recommend mark your answer as the accepted one so the questions will change to "answered"

avatar image
1

Answer by d2clon · Jul 28, 2021 at 06:39 PM

It sounds to me that there is an Animation setting it as disable.

Animations run after the Update() so this means they also run after the Awake() (https://docs.unity3d.com/Manual/ExecutionOrder.html).. try to put theVar.SetActive(true); in the LateUpdate(). If it works that may be a confirmation of the Animation theory

Comment
Add comment · Show 3 · 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 TwistedDevelopments · Jul 28, 2021 at 06:47 PM 0
Share

Unfortunately I don't think it's that as I have no animations going in my project yet, none imported or used. It's strange, every time I click play the object disables itself. If I check the box for the object while I'm in play mode though, the object becomes active and operates as it should. I tried to use the SetActive as the first thing my code read after the vars declared at the top of the script. I've even tried resetting Unity and my PC but to no avail

avatar image TwistedDevelopments · Jul 28, 2021 at 06:52 PM 0
Share

To make sure I tested your theory and unfortunately it didn't help. Thanks anyway though

avatar image d2clon TwistedDevelopments · Jul 28, 2021 at 07:16 PM 0
Share

Another thing I would try is to remove the Object form the Scene and create it again (or duplicate it and remove the original) to see if there is any other Object deactivating it by reference.. also try to change the name of the object.

avatar image
1

Answer by petur · Jul 28, 2021 at 07:40 PM

If you discarded animations and your own scripts, the only other two options I can think right now are:

  • Some gameobject up the hierarchy (parent or parent of the parent) could be disabled, in which case all other childs would be disabled too. In code, this state can be identified as "activeInHierarchy", as oposed to "activeSelf". Fixing this would require changing your hierarchy structure or which parts of it you disable.

  • Other script you have imported is disabling your gameobject. This can be difficult to track. If you don't have a lot of code you can search in all files for "SetActive(" and check if any instances found could be the problem. Another way to find the culprit would be to try to mess with how that script references/finds your gameobject to disable it. It could have direct reference, (in which case a copy pasted version of the object would not be afected), it could be by name, in which case changing the name of your go would suffice, it could be position in the hierarchy, try placing a copy somewhere else, it could be by tag, try changing the tags of your gameobject, it could be searching by a particular component, try removing all components and pressing play.

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 TwistedDevelopments · Jul 28, 2021 at 07:53 PM 0
Share

I updated Unity and it fixed whatever was wrong. I had thought along those lines and started a new project and started a fresh, it did the same so I just updated and it's fine now.

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

124 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

physics.OverlapSphere colliders 1 Answer

Alternatives to GameObject.SetActive(...) 2 Answers

Conflicting Box Colliders 0 Answers

C# iOS - .active, SetActive(false) 0 Answers

SetActive(true) dont work 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