Search Unity

[Release] Emergency Exit! Break out of infinite loops

Discussion in 'Assets and Asset Store' started by Aevus_I, May 6, 2021.

  1. Aevus_I

    Aevus_I

    Joined:
    May 6, 2021
    Posts:
    2
    Hello Everyone!

    I present to you: Emergency Exit

    We have all encountered an infinite loops in the editor before. These can be incredibly frustrating, because the unity editor just stops working. This can cause a lot of lost work, because you may have to forcibly close unity without saving.

    But fret not, because with Emergency Exit you can break out of any infinite loop in the main thread, no matter if you are in play mode, edit mode or build!

    How this works

    This works by spinning up a new thread which just waits in the background for the Emergency Keycodes. Once those have been pressed, the new thread will then throw a special exception into the main thread, which will then break out of anything and the execution will go back to unity. Once the Emergency Exit is trigger, unity will be paused, so that it will not enter the infinite loop again. From there you can either stop playmode and return back into the editor, or you can even continue if you exit pause mode and everything will work without issue!

    Support
    • unity 2017 to current (2021)
    • Currently only windows is supported. (if you can help me get user Input from non-windows systems which bypasses the unity input system, please send me an email aevus.sm@gmail.com)

    You can get this tool from the asset store here: http://u3d.as/2wxG
     
    Last edited: May 14, 2021
    pierre92nicot likes this.
  2. huulong

    huulong

    Joined:
    Jul 1, 2013
    Posts:
    224
    Cool, was looking for a replacement for the latest Unity.

    PanicButton was handling Windows and OSX, but maybe you've already looked at their code and couldn't find a way to port it? I'm personally lost into it so I can't really tell you how it's done...

    And then in the meantime, Linux appeared (which I'm using right now), which is an extra challenge, for which I won't be able to help either... But if you manage to support it, post an update here, I'll watch this space!
     
  3. esteban16108

    esteban16108

    Joined:
    Jan 23, 2014
    Posts:
    159
    This is amazing. Thank you
     
  4. sonnyb

    sonnyb

    Joined:
    Nov 5, 2013
    Posts:
    17
    On Unity 2021.3.3 + Emergency Exit 1.1.0, I had to modify this line in
    EmergencyExit.cs
    's
    CatchThreadAbort
    method:

    if (type == LogType.Exception && condition == "ThreadAbortException")


    to:

    if (type == LogType.Exception && condition.StartsWith("ThreadAbortException"))


    because the
    condition
    is
    ThreadAbortException: Thread was being aborted.
     
    fe2prx6b likes this.