Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by maruudn · Mar 07, 2016 at 10:49 AM · c#unity 5parentchildactive

Parent is not active...but there is no parent!

I have sort of a complicated question, and I'm not quite sure how to word myself... So please bear with me.

So I have a scene that instantiates a GameObject with a script on it, that sorta kicks off the whole thing. This GameObject, named GameManager, is not destroyed upon loading new scenes using DontDestroyOnLoad(gameObject);. So the first thing my GameManager script does, is to play a little hard-coded "intro animation", and then loads the main menu of my game. The "animation" plays as a float timerdecreases in the Update() function like this:

 if(timer > 0)
 {
     timer -= Time.deltaTime;
     return;
 }
 else if(timer <= 0 && loading)
 {
     changeLevel(nextLevel);
     return;
 }

As you can see, once timer is 0, a function changeLevel(nextLevel) is called. nextLevel is simply and int that says which level to load. loading is a bool that is set false in the changeLevel() function to prevent it from being called every frame.

In the main menu, there's a Canvas that holds all the GUI-elements, and this canvas has a script, MainMenu.cs. In this script I have made a variable for the GameManager script named gm, so that I can access public variables and functions. And so when I press play in the main menu, I try calling a function in the GameManager script called splash() like this: gm.splash(), as well as setting gm.nextLevel = 2 to let it know what level to load next. The splash() function simply instantiates a Canvas, and sets my float timer to 3 in the GameManager script, so that it should take 3 seconds before loading the next level.

Now here comes my question. The Update() function in my GameManager script does not seem to be called every frame, like it should. I was doing some digging and I tried checking whether the object was active or not using gm.gameObject.activeSelf in the MainMenu script, and it is. But it seems the parent is not active, which I checked with gm.gameObject.activeInHierarchy from the MainMenu script. Thing is, my GameManager object does not have a parent, it's just there in the hierarchy all by itself. And since it's not destroyed upon loading new scenes, it should still be active, no?

Sorry for the long question, but I felt it necessary to give the whole backstory to my situation for you guys to sorta understand my question... Thanks for taking the time to look at my problem! :)

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 maruudn · Mar 06, 2016 at 04:03 PM 0
Share

After a little bit of processing, I've come to the conclusion that it makes sense for the "parent" of my Game$$anonymous$$anager object not to be active, as it doesn't exist... If it's null, then I assume it's also inactive.

This doesn't resolve my problem though, as to why the Update() function isn't running each frame, so I'm not going to delete my initial question.

I might add that I tried to use a Coroutine to achieve the wait of 3 seconds before loading the next scene, but then I get an error saying Coroutine couldn't be started because the game object 'Game$$anonymous$$anager' is inactive!, so that leaves me pretty much at the same spot.

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Why can't I access the public variables of the children class of TestItem in this syntax? I only have access to TestItem variables 1 Answer

Can not access GetComponentInParent ( ). usegravity 1 Answer

[PUN] Change Parent's GameObject in Network 0 Answers

Child an Object to Another Objects Parent On Collision 1 Answer

Parenting objects with code not working 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