Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by FourSheds · Sep 05, 2010 at 08:09 PM · forcefreezequit

Can I force game execution to stop in the editor?

Hi

Supposing I have a bug which caused an infinite loop (or any other lock-up), is there a way (while in the editor) to force-stop the game running? Maybe a key combo or such like?

I ask because this just happened to me and I had to force quit Unity and lost 15 minutes work.

Thanks

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
10
Best Answer

Answer by qJake · Sep 05, 2010 at 08:49 PM

Use Debug.Break();

http://unity3d.com/support/documentation/ScriptReference/Debug.Break.html

Ctrl+Shift+P also does the same thing (pauses).

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image FourSheds · Sep 05, 2010 at 09:55 PM 0
Share

Thanks, just what I needed :)

avatar image Rafes · Jun 16, 2014 at 02:57 AM 2
Share

This actually stopped an infinite loop? Debug.Break is only supposed to stop at the end of the current frame. A loop implies it never gets there.

avatar image Fr33zerPop · May 31, 2018 at 12:18 AM 0
Share

Yes, but how do we abort game execution in Play mode (play button has been pressed) without having to force-quit Unity (and potentially lose work). Ctrl+shift+p doesn't do that for me on my $$anonymous$$ac.

avatar image Shaba1 · Aug 31, 2018 at 03:15 AM 0
Share

The docs for Debug.Break() says that it PAUSES tje editor. Is there a way in a script to completely STOP The playmode? As if the uset had press the blue play button on the editor and it turns black?

avatar image Hellium Shaba1 · Aug 31, 2018 at 05:10 AM 1
Share
 #if UNITY_EDITOR
 UnityEditor.EditorApplication.isPlaying = false;
 #endif
avatar image
1

Answer by Venryx · Oct 15, 2016 at 06:30 AM

You can attach the debugger from MonoDevelop or Visual Studio, then change the variables and such to make the loop break.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image craftstar · Feb 01, 2017 at 03:54 PM 1
Share

For infinite loop problems try this: https://blogs.unity3d.com/2016/05/24/breakout-how-to-stop-an-infinite-loop-in-a-unity-c-script/

There are also plugin solutions out there like this: https://www.assetstore.unity3d.com/en/#!/content/40167

avatar image
1

Answer by DDaddySupreme · Jul 15, 2017 at 09:00 AM

What I do is I implement a count int (set to 0) before every while loop. At the end of the loop add one to it, and somewhere else add an if statement that uses Debug.Break() and Debug.LogError("") if count gets above 100, or any other number that it should never get to. This way you can also leave an error message to see what happened.

Not quite an answer to the question, but it's a good preventative measure.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image the_nem_s · Feb 06, 2021 at 06:40 PM 0
Share

Can you please shoe me a example?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

force quitting 2 Answers

Admob Plugin - Android Manifest Problem 1 Answer

Linux build freezes on application.quit 0 Answers

Unity freezes on Quit (4.3) 2 Answers

Unity keeps force quitting on Mac no matter how small my action is? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges