- Home /
Why does unity editor hang when play button is pressed.
I am having a problem. Whenever I press the play button on the Unity Editor It freezes my whole program. I have to go to the Windows Task Manager and End Task it. Does anyone know why that happens and how to fix it?
Also I am running windows 7 64 bit edition if that will help.
It sounds like a script problem. Can you post any potentially problematic script or give any further information such as in-game operations or when the problem started occurring?
The thing is, it has been happening since I installed unity. At first I thought it was my ARCamera (using QCAR toolkit) but then i also noticed that it happens when all i have are an empty project and a script that adds gui
void OnGUI() { if(GUI.Button(new Rect(...), "some Title") { Debug.Log("Some debug test"); } }
and like I said in the other answers this happens sporatically, a couple times right after i turn on my computer and unity, and then every couple of times i press play afterwards,(yes even with an empty project i want to check out).
A lot of freezes and crashes come from firewalls or an anti-virus program.
Shot in the dark I know but try disabling such programs and try again.
Did somebody find a solution to this? I am having the same problem for a couple of days now, really annoying. I already tried re-installing different versions of Unity, different drivers for my graphics card, running as ad$$anonymous$$istrator, changing player settings.
Anyone?
Answer by Raigex · Aug 16, 2012 at 08:41 PM
This was a pure accident but I have found what hangs my Unity Editor. It hangs when my player settings are set to Android. When it hung I turned on my task manager to end task it but the tab was processes. I noticed that I had like 20 adb.exe running (one for each time it hung). I started deleting them and like magic the play button works.
So my answer is (only for ANDROID so far) If your unity editor hangs, check your task manager and delete all your adb.exe this should allow it to continue to function.
I also experienced this for last couple of days...very frustrating..at first I thought it becaused I upgraded to 4.2 from 3.5.7, but then I reinstalled 3.5.7 but problem still there.. I tried to switch platform but no good... But I recalled that I just upgraded android SD$$anonymous$$ from 16 to the latest, because unity 4.2 need that upgrade...I think since then the problem arose... But, fortunately, the build command is not effected...I can still build the project to android apk...
THAN$$anonymous$$ YOU SO $$anonymous$$UCH. You saved me a lot of headache in the future. Too bad I didnt look for the answer BEFORE quitting unity though...but it's ok I learnt something useful at least.
Thanks man, i had the same problem BUT i was using Win/$$anonymous$$ac/Linux platform...$$anonymous$$y Unity version is 4.2.2 so i don't think this is a platform issue. I ended adb.exe processes and it helped me )
I had the same freezing problem and found your post. I deleted the adb.exe processes and it fixed my freezing/hanging problem. Thanks a ton!
Here's my post: http://answers.unity3d.com/questions/621341/432-freezes-when-i-click-play.html
Answer by Bunny83 · Jul 20, 2012 at 01:18 PM
You probably coded an infinite loop somewhere that runs at start...
Try disabling your scripts to see which one is the faulty one and then add it to your question by press edit.
If there was an infinite loop it would hang all the time. This happens even when all I have is an OnGui function with a if(GUI.Button(...)) function. Not always but it happens.
Do you mean you've tried creating a new empty project and when you run it, it still freezes?
Yes, not always but the first couple of times i press play it freezes. I have to end task it and then turn on unity again. I do this 2 or 3 times until finally it starts working but the constant restarts are getting annoying. Also my target platform is the Android, if that changes anything. And when it hangs the play pause and fastforward buttons dont even turn blue, the play just gets stuck in clicked mode and i cannot do anything in unity anymore
Actually this happens to me frequently (but inconsistenly) as well. Especially if debugging, but in some cases when I am not. It has been happening since I started developing in Unity and I have switched between multiple different projects (and languages, and versions) over that time. I've been living with it, but would dearly love to know what is happening. I'm running on a $$anonymous$$ac with nothing very special going on.
I've been wondering if it is Time $$anonymous$$achine
So I guess we are two of the few unlucky ones that this happens to. Damn i guess I'll have to live with it.
Answer by wreyes · Mar 11, 2015 at 09:26 AM
I had the same issue. Mine was cause by the NavMesh. I cleared the baked NavMesh and all was fine. My thoughts are that there was too much data.
An FYI, I was able to debug this by using the Profiler (Unity Pro Only I believe).
Hope that helps.
Answer by regie · Jul 19, 2012 at 02:49 PM
It is possible that it has nothing with your computer. Check if you haven't some exceptions, objects have references to scripts, etc. I had the same problem.
No exceptions found. $$anonymous$$y Console is clear. I just hangs when i press play especially the first couple of times after i turn on my computer.
Answer by ashfaqueck · Nov 08, 2016 at 12:59 PM
using UnityEngine; using System.Collections;
public class Scroller : MonoBehaviour {
public int maxPlatform = 20;
public GameObject platForm;
public float horizontalMax=14f;
public float horizontalMin=6.5f;
public float verticalMax=6f;
public float verticalMin=-6f;
private Vector2 originPosition;
// Use this for initialization
void Start ()
{
originPosition = transform.position;
spawn();
}
// Update is called once per frame
void Update ()
{
}
void spawn()
{
for (int i = 0; i < maxPlatform; i++)
{
Vector2 randomPosition=originPosition+ new Vector2 (Random.Range(horizontalMin,horizontalMax),Random.Range(verticalMin,verticalMax));
Instantiate(platForm, randomPosition, Quaternion.identity);
originPosition = randomPosition;
}
}
}