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.

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>();