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 /
This question was closed Dec 11, 2014 at 09:11 AM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by kylerk · Dec 11, 2014 at 09:08 AM · editorplaystartup

Extremely slow to enter playmode (50 seconds) what is the source of the problem?

The game I am working on has fairly peculiar needs, mainly thousands of sprites, each their own gameobject, with code running on them to update them to their appropriate sprite.

The game runs perfectly fine once it is started, easily at 60-70 fps. I have some decent optimization that works well.

When I build the game, it runs well. Loading time is perfectly acceptable, somewhere in the realm of 10 seconds.

The problem is that in the editor, every time I press the play button, I have to wait 50-60 seconds before playback actually starts. I've been trying out different things to figure out what the problem is, but I still can't locate it.

Here are somethings I know.

  1. The more sprites with scripts attached I add, the worse it gets.

  2. If I get rid of the scripts attached to the sprites, it get's much better, even if there are still thousands of game objects.

  3. Here is the main code in the Start() sections of the scripts that are attached the problematic gameobjects.

    void Start() {

          if (!omniSpritesContentStart)
             {
                 omniSpritesContentStart = GetComponent<OmniSpriteContent>();
             }
             spriteRenderer = GetComponent<SpriteRenderer>();
             growControl = GetComponent<GrowControl>();
     
             newSpriteContent = omniSpritesContentStart.GetSprite(this);
             spriteRenderer.sprite = newSpriteContent.sprite;
     
             StartCoroutine("UpdateSprite");
             StartCoroutine(UpdateOmniSpriteData());
     
         }
    
    

and

 void Start()
     {
 
         audioSource = transform.parent.GetComponent<AudioSource>();
 
         if (controlObject)
         {
             trigger = controlObject.GetComponentInChildren<PopControl>();
         }
         else
         {
             //  The Grow Control will search for a popcan at in the Same Group level as the plant itself
             controlObject = transform.parent.parent.GetComponentInChildren<PopControl>().gameObject;
             trigger = controlObject.GetComponentInChildren<PopControl>();
         }
 
         omniSprite = GetComponent<OmniSprite>();
 
     }

I feel it's important to note again that the playback on a game build of the game is normal, the load is only about 5 - 10 seconds, but in the editor it's so much longer.

Is there anything obvious that I am missing?

Does anybody have any good information about what is happening after I press the play button, and why it is taking so long. I don't have pro Unity, so I can't use the profiler if that is something that would help.

If you have any ideas, let me know. Perhaps there is some preference I can change to improve this?

Thanks.

Comment
Add comment · Show 3
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 meat5000 ♦ · Dec 11, 2014 at 12:31 AM 0
Share

Overheads are actually a lot larger in editor than in Build. From what I've seen this is still actually normal.

Coroutines in Start() can also cause delays. Don't forget Coroutines are not multithreaded. Everything still waits for it. Having this code in Start() could well be causing your delay.

avatar image meat5000 ♦ · Dec 11, 2014 at 01:14 AM 0
Share

Try moving the two Coroutines somewhere else. See what happens.

avatar image kylerk · Dec 11, 2014 at 02:16 AM 0
Share

I fixed the bit of code that was causing the problem and it's all better at a 10 second start up! Fantastic.

THanks for your help

1 Reply

  • Sort: 
avatar image
2
Best Answer

Answer by kylerk · Dec 11, 2014 at 02:03 AM

Found the cause! It was this code. Eck. I see the problem. Traversing up a tree twice was really really stupid. And was causing an explosion in the search size.

   controlObject = transform.parent.parent.GetComponentInChildren<PopControl>().gameObject;
              trigger = controlObject.GetComponentInChildren<PopControl>();
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 meat5000 ♦ · Dec 11, 2014 at 09:10 AM 0
Share

Ha. Indeed. The parent.parent is actually pretty quick, but as you say greatly increased the size of the GCIC() searches.

Accept your own answer. Published to add good info to the database :)

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Why does object movement get saved to scene editor? 2 Answers

Running a script when Unity starts. 3 Answers

Limit on x rotation axis in play mode 2 Answers

Unity stops after showing splash screen. 1 Answer

Unity Editor Crashes Upon Startup 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