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 boddole · Dec 12, 2015 at 11:22 AM · loadingloadlevelfindfind-gameobject

Trouble with GameObject.Find() After LoadLevel.Load()

Hello everyone, I'm having trouble understanding why GameObject.Find() cannot find a gameObject after a Application.Load(). Essentially, after I load my level, it takes 1 additional frame before GameObject.Find() can find my object. alt text As suggested by bdev in this thread: [http://forum.unity3d.com/threads/finding-objects-after-a-scene-load.106809/], I used two coroutines to call LoadLevel(), then wait a few frames before trying to Find() anything in them.

 IEnumerator LoadLevel( string levelName )
 {
 Application.LoadLevel(levelName); yield return null; yield return null;
 }
 
 IEnumerator LoadLevelAndProcess(string levelName) {
 yield return StartCoroutine( LoadLevel( levelName ) );// loads level waits 2 frames.
 // insert find code here. everything *should* be ready at this point.
 }

Unfortuantley, whether I use these extra coroutines or not, I still get the same result, the level loads, Find() won't work for 1 frame, then everything is fine.

             #if DebugMaster
             Debug.Log("TransToReal detected...");
             #endif
 
             while(GameObject.Find("3cRealLoadingScreenElements[enabled set1]") == null)
             {
                 #if DebugMaster
                 Debug.Log("3cRealLoadingScreenElements[enabled set1] not yet found...");
                 #endif
 
                 yield return null;
             }
 
             realLoadingScreenHierarchy = GameObject.Find("3cRealLoadingScreenElements[enabled set1]").GetComponent<UIWidget>(); //should immediately exist...

Any ideas on why this happens is appreciated, thank you for reading.

editor-screen.jpg (307.5 kB)
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 ModLunar · Jul 02, 2018 at 08:42 PM 0
Share

Still having this problem in 2018 with the relatively newer Scene$$anonymous$$anager.LoadScene(...) under UnityEngine.Scene$$anonymous$$anagement. If I use a coroutine to wait a few frames after the call to Scene$$anonymous$$anager.LoadScene(...), the GameObjects I want are found by my tag, but that's after everyone else's Awakes and Starts were called, letting all hell break loose with the Null exceptions everywhere.. I'm seeing so much red T_T

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

33 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

Related Questions

Load Level script problem 2 Answers

Async Level loading issue. 0 Answers

GameObject.Find doesn't return elements of new scene 0 Answers

GameObject.Find throws be a error when trying to find a child. 1 Answer

How do I make a level code system? 3 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