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 makertoo · Jun 17, 2020 at 08:55 AM · loadlevelasync

LoadLevelAsync progress doesn't include Awake() of the next scene

Hey,
I am working on making a transition scene and I need help.
On the menu scene, Play button do the loadSceneAsync with a transition (or a loading bar, I tried both ways).
The load bar finishes as the LoadSceneAsync is "isDone ", otherwise it shows the progress (slider tutorial..you know the standard way).
My issue is that the game freezes before showing the next scene and I don't know what to do. Important information: The Awake() method of the next scene serialize an xml file into a class, and this what causes the freeze.

The Awake method:

         InitializeServices();

Within the InitializeServices, there is this line:

             using (StringReader reader = new StringReader(xmlWTF))
             {
                 this.WordTreeFreqNode = (WordTreeFrequencyNode)xs.Deserialize(reader);
             }

xmlWTF is a path to a xml file. This line reads a file and deserialize it: it is always the same file content to deserialize each time. This line is what make the game "freezes". The deserialization is however necessary.

  1. Do you know how to do in these situations? What are the best practice?

  2. Is there a way to include Awake() of the next scene into progression?

Thanks

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by FrameXdropProvrex · Jun 17, 2020 at 06:01 PM

A rule of thumb is to only use Awake to initialize the script and communicate within the script while the Start method is used to communicate with other scripts. If the Awake method doesn't communicate with other scripts i don't know what the problem is. Maybe sharing the part of the awake method will give more insight.

Comment
Add comment · Show 4 · 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 makertoo · Jun 17, 2020 at 06:34 PM 0
Share

Thanks, I just updated the question with the code

avatar image FrameXdropProvrex makertoo · Jun 17, 2020 at 09:31 PM 0
Share

Can you show me the part where you create the XmlSerializer (xs)?

Are you creating a new XmlSerializer before deserializing the file? Because then there's no reason to hardcast it to WordTreeFreqNode.

 XmlSerializer xs = new XmlSerializer(typeof(WordTreeFreqNode));

 this.WordTreeFreqNode = xs.Deserialize(reader);


I don't know for sure, but hardcasting can cause problems from time to time and is best to be avoided.

avatar image makertoo FrameXdropProvrex · Jun 17, 2020 at 10:16 PM 0
Share
            //Here we are just going to deserialize the X$$anonymous$$L where the Word Tree Frequency was generated
             XmlSerializer xs = new XmlSerializer(typeof(WordTreeFrequencyNode));
 
             using (StringReader reader = new StringReader(xmlWTF))
             {
                 this.WordTreeFreqNode = (WordTreeFrequencyNode)xs.Deserialize(reader);
             }

This is the code. Do you have any idea how do serialize? Are there a better "unity" wayd to deal with it ? I need to retrieve the content of the xml file for my game to run. The Xml file is quite heavy 100mb, it is loaded from a prefab with:

 var xmlFile = Resources.Load<TextAsset>("WTFRX$$anonymous$$L");

To sum up:
1- The WTFRX$$anonymous$$L prefab is loaded from asset by Resources.Load =>xmlFile.
2- The xmlFile.text is serialized into WordTreeFrequencyNode.

Show more comments

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

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

Related Questions

Application.LoadLevelAsync() causes Unity crash? 2 Answers

How do I stop the GUI from flickering on a new scene? 0 Answers

Got a problem with Async! 0 Answers

Async Scene Creation 1 Answer

Geometry not rendering after Application.LoadLevelAdditive 0 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