- Home /
Unity Takes Forever to Exit Play Mode
This just started yesterday and the only thing I can think of that I changed was creating a GUI.Window and changing a model which threw a convex mesh collider error and I had to turn convex off.
Anyways when I play my game it takes the usual 10 seconds to load, but when I stop the play mode it takes 10-30 minutes to actually stop, it just freezes until it's done.
I might as well just close unity and reopen it, probably faster.
Thought I might need to mention that if I click pause it's fine, I can pause/unpause perfectly fine but no matter what if I click the stop button it pauses.
Have you added any OnDestroy(), OnApplicationQuit() hooks or similar?
Also check OnDisable. Unity disables, and destroys every object in the heirarchy before calling ApplicationQuit
Thank you for the reply, I ran a scan through all of my scripts again and it returned 0 instances.
The only exit type function I have is OnDisconnectedFromServer. I will check those ones.
Update: Just checked it and there are no differences from before this happened, there's only 1 instance of OnDisconnectedFromServer anyway.
I don't know if this will help you guys or not, but today I went to debug multiplayer with my friends (luckily, for the first time ever, there were no mp-side bugs!), and I found that me and all of my friends' games took around 5-10 $$anonymous$$utes to quit as well.
$$anonymous$$eep in $$anonymous$$d that this is in the build now, not the editor.
This is slowing my development down quite a bit so if anybody figures it out for me then I would really really appreciate it! :)
Also, I apologize if some of my messages have a few grammar/spelling mistakes, I have good grammar and spelling but I keep not paying attention while thinking of what to say.
If you have a problem you cant solve just roll back to a previous version, and look for differences.
I was gonna do that, but the last backup was about a month ago and I've made a crapload of progress since then.
It would probably take days if not weeks.
I guess I might have to try, though.
Answer by protopop · Feb 20, 2017 at 06:45 AM
My game was set to High Quality in the editor but Low on Play. So when I would exit play mode there was a long pause while it switched all the textures to the higher resolution. This was an accident and once i set it so play mode and the editor both used the same quality level the pause went away.
Answer by DroidifyDevs · May 28, 2016 at 10:13 PM
That's weird. Did you try making a new, blank project then try starting and exiting play mode in the new project? Need to see if this is an issue with your project, PC, Unity3D or all of those.
I can try that, but this just randomly started so it's either Unity or my project.
Okay so I tried a blank project and it still takes 10 seconds to click play (that has always happened, I'm used to it) but it leaves play mode instantly.
What are some issues that could cause this?
I tried a blank SCENE in the same project and it freezes as well.
So it's the project, not the scene.
Update: It is in the scene but if I opening my loading screen scene and let it load until it gets to the scene that freezes, it doesn't freeze when stopping the game.
So it's only when the Editor is on that scene but if I were to load that scene it won't happen.
Answer by MallNinjaMax · Sep 05, 2019 at 07:58 PM
I was having a similar issue, so I'll throw out my anecdote. I found out it was my tiny editor script I was no longer using, slowing down the exit from Play mode. When I commented OnInspectorGUI() out, everything went back to normal. Here's the script that was slowing it down:
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(CoverPoints))]
public class CoverCalculator : Editor
{
public override void OnInspectorGUI ()
{
DrawDefaultInspector();
CoverPoints coverPoints = (CoverPoints)target;
if(GUILayout.Button(new GUIContent("Calculate", "Calculate cover points.")))
{
coverPoints.Calculate();
}
}
}
I get that OnInspectorGUI is probably a hefty function, but can anyone explain why it slows down the editor so much? It would be nice to use editor scripts in the future without completely killing my iteration time.
Your answer
