Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Way to stop game from running when in an infinite loop or a hang

Discussion in 'Editor & General Support' started by dogfacedesign, Nov 21, 2018.

  1. dogfacedesign

    dogfacedesign

    Joined:
    Jan 10, 2016
    Posts:
    70
    Quick question. I find myself debugging a rather tricky piece of code, which currently ends up in an infinite loop. Is there some sort of way to stop the app from running without having to kill the editor process? Unfortunately, clicking the play or pause button is unresponsive. :(

    Thanks in advance for any suggestions!
     
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,930
    Not really.

    But put this in the loop while you're working on it:
    Code (CSharp):
    1. if (Input.GetKeyDown(KeyCode.Escape))  break;
    So you can break out from the loop on ESC key.
     
  3. dogfacedesign

    dogfacedesign

    Joined:
    Jan 10, 2016
    Posts:
    70
    Derp! Why didn't I think of that before hehhehe. Thanks!