Editor's play button doesn't work after editing a script

v: Unity 2020.3.8f1

Whenever I press the play button after editing a script, the play button gets stuck (it becomes dark as if the game was playing) and you can’t unstuck it. Meanwhile, the game is not playing. The only way to get out of this situation is to close the program and restart. On restart, the game will play normally if I hit the play button until I edit a script and it fails again. Note that unity itself is not frozen. I can go in the scene and edit things.

Best guess is that there’s no re-compiling after the script edit happened and that screws up everything else. I can’t reproduce the issue with a blank project.

Before you make me delete everything one by one or re-add everything one by one, is there anything that you can think of that could make this issue happen? I added Bolt recently to my project and I’m thinking maybe it has something to do with it but I don’t know.

This typically happens when you create an infinite loop in a script, which causes Unity to hang endlessly.

Can you share the code that you tried changing?

I can’t share the code but it shouldn’t matter because:

  1. This doesn’t just happen on one script but on any script. As soon as I edit and re-save any code on any script, the problem occurs. Even just adding a “Debug.Log();” and saving will cause it.

  2. When I restart unity with the updated code still saved, I can run play mode with no issue (until I make any other edit and save)

There could still be some loop somewhere though that gets triggered on recompilation. Not sure why it would happen on re-compilation but not when starting up Unity though.

I would guess some sort of faulty asset importer or postprocessor… they run any time when you import or save something.

1 Like

If anyone ever ends up here again:

I upgraded to 2021.1.7f1 and then downgraded back to Unity 2020.3.8f1 and somehow that seems to have fixed it? I don’t get the problem anymore.

Been having this issue quite regularly with Unity 2023.1.0 through all of the betas 1 to 16 so far.

Hi, I am having the same or similar problem…
Yesterday my build was working perfectly and the unity editor let me test the experience without problems in my quest 2.
Today, I have continued where I left off and it seems that the “Play” of the unity editor does not finish loading the scene and stays in “loading…” mode. The strange thing is that I have not changed anything and the music of the experience can be heard in the background…
I’ve tried everything already, reset my VR quest 2 glasses, delete the last steps of the programming (although it didn’t make much sense because yesterday it worked…).
Do you know how to clear the unity cache? Maybe it got stuck in some loop and now it is not able to work again.
Extra information is that if I open another project, the “Play” works without problems.
Thank you!