Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by d112570 · May 05, 2014 at 12:42 PM · debugbreak

Debug.Break() ; not working properly

I have this code

 Debug.Break() ;
 print("Break was ignored")

When I run the script " I see Break was ignored" in the console. I am trying to test my variables and I am unable to test them since I get the results back that was posted after the debug break. I have another line after print and the whole script gets called, so I am unable to check my variables before the break was issued.

 Debug.Break() ;
 print("Break was ignored");
 EditGridColor(thePath);

Do I under stand Break wrong? I am trying to pause the app so I can see the where I am currently at and why my results are not how they should be.

also if I have 2 Breaks, the app will only break one, so I can't break, continue, break, continue. I will only do break continue, does not matter how many breaks you have, even if you have like 10 breaks.

 Debug.Break() ;
 print("Break was ignored");
 EditGridColor(thePath);
 Debug.Break() ;
 print("This Break was totally ignored");

P.S. After Debug.Break(), all the scripts ran and then game paused.

Comment
Add comment · Show 2
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 robertbu · May 05, 2014 at 01:32 PM 1
Share

As a workaround, you can use the $$anonymous$$onodevelop degbugger.

http://unitygems.com/debugging-game-monodevelop/

avatar image sosh · Nov 17, 2014 at 04:48 PM 0
Share

Debug.Break() seems to be ignored for me too....

4 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by Bunny83 · Nov 17, 2014 at 05:01 PM

Debug.Break just pauses the editor when the current frame is finished. It's just like you clicked on the pause button manually but you can trigger it at a specific frame. If you want to do code analysis you have to use the debugger like robertbu said. There you can set break points on every line you want.

edit
Unfortunately the unitygems site seems to be hacked / offline for some weeks now. Here's Unity's documentation on the debugger.

Comment
Add comment · 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
1

Answer by liveswithoutfear · Mar 29, 2021 at 10:37 AM

I know this is an older thread but I thought I could weigh in, in case someone else comes across this and it might help. If you want to pause the editor and stop the rest of the code from running then after Debug.Break(); just add return; This will stop the rest of the code running in that script, it'll become obvious because in visual studio the code underneath "return;" will become dim. It won't, however, stop the rest of the code in other scripts from running at the moment return is called, every other script will still finish its update frame.

Comment
Add comment · 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
0

Answer by Venryx · Sep 11, 2016 at 02:38 PM

Here is a solution that gets basically what you want:
1) Copy the System.Windows.Forms.dll file into your Assets folder somewhere. (you can find it here: C:\Program Files\Unity\Editor\Data\Mono\lib\mono\2.0)
2) Add these lines in place of the "Debug.Break();" line:

     MessageBox.Show("Something happened. Attach the debugger, add a breakpoint to the line after this one, then press OK.");
     "does nothing".ToString(); // place breakpoint here

Now when that area of code is hit, the message-box will show, and will block the code execution. Then just add the breakpoint to the line after (as it says), press OK, and the code will resume and hit the breakpoint you just added.

It's a bit more work than just a BreakHere(); call, but it accomplishes the same thing.

Edit
==========
For those who don't want to add a DLL to their project, you can also just call the User32.dll's MessageBox method directly.

Here's a paste-bin showing the working code for this variant: http://pastebin.com/JF5RVG6Y

In this case, you'd call "Assert(false);" from the line where you want to break. (then just use the "Call stack" window to go up one method and inspect the state)

Comment
Add comment · Show 2 · 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 kornica3d · Feb 08, 2018 at 03:27 PM 1
Share

Doesnt work... $$anonymous$$essageBox is being highlighted as error. DO you use it with Visual Studio?

avatar image Venryx kornica3d · Feb 08, 2018 at 05:24 PM 0
Share

I think I did use it in Visual Studio, yes. However, even if it shows an error in VIsual Studio, it should still be able to compile in Unity (different compiler chain). So try making the change anyway, and seeing if it works.

If not, then are you sure you're using the exact DLL I referenced? If you are, then it may just be that they updated the code somewhere -- I haven't used Unity in months so I don't know if this approach works with the latest versions. (I know it worked earlier since I relied on it heavily for certain debugging tasks)

avatar image
0

Answer by kornica3d · Feb 08, 2018 at 03:31 PM

Even i figured out u have to do System.Windows.Forms.MessageBox, still window shows but as i click okay nothing is happening the game keeps on going afterwards

Comment
Add comment · 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

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

25 People are following this question.

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

Related Questions

Strange Debug.Break() behavior 2 Answers

How do I stop/pause/break a build automatically on error? 3 Answers

Filing and debuging web plugin crashes 1 Answer

"It is not possible to invoke an expression of type 'boolean'" in switching cameras 1 Answer

Turn off blue mesh lines 2 Answers


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