Restore "debugger mode" setting upon editor restart

Please implement to save and restore the “debug mode” option, so I don’t have to turn it on every time I restart Unity.

I’m talking about this option:
5727580--600445--upload_2020-4-17_17-8-39.png

The current implementation is not useful, because:

  • Start Unity

  • Enter playmode

  • See something suspicious

  • Switch to Visual Studio, set breakpoint

  • Hit “Attach debugger” button

  • Nothing happens

  • Switch back to Unity to see whats wrong

  • Get greeted with this dialog:

5727580--600448--upload_2020-4-17_17-11-49.png

  • Press “Switch to debug mode”

  • Unity exits playmode

  • Unity recompiles

  • Unity finished and ready to debug

… aaaand what I wanted to debug is lost, because Unity exited playmode and recompiled.

5 Likes

It’s there in preferences:

4 Likes

Nice, thanks for the tip!

Here is some feedback for this dialog:

  • Add text that tells it’s possible to switch to debug mode permanently via Preferences using “Code Optimization On Startup”.

  • Add “Switch to debug mode permanently” button.

  • Mention that “switch to debug mode” also exits playmode.

  • Think about using the same terminology (“debug mode” vs “code optimization”).

6 Likes

It doesn’t exit play mode.

Well, it did for me.

1 Like

It will depend on the setting for compilation during play mode as scripts will recompile once this setting is also enabled.

1 Like

Is this something new since 2019? I noticed since switching to 2019 that whenever I attach the debugger it tries to recompile something, sometimes even requiring to restart playback (not always).
This didn’t happen in unity 2018, now attaching the debugger is super slow at least with visual studio.

I think this is a 2020 thing, I’ve never seen this dialog box in 2019 and I’m definitely attaching the debugger at pretty random points in time.

Thank you for the feedback. We got similar feedback from developers internally and before I was made aware of this thread, I already had a change pending to change this dialog. It hasn’t landed yet.


Multiple people internally have mentioned that “Switch to debug mode for all sessions” is confusing. Do you think “Switch to debug mode permanently” is more clear?

I think it makes sense to add this.

I think this only happens if you have "Script Changes While Playing" set to “Stop Playing And Recompile

3 Likes

Is the API in place so we can create our own buttons for “switch to debug mode and enter play mode” or “switch to optimized mode and enter play mode”?

Hi Lukas,

thanks for your answer and asking for further feedback.

Both sound fine to me, but let me throw in a few more ideas:

Enable debug mode | Cancel | Enable debug mode temporarily

Disable C# optimization | Cancel | Disable C# optimization temporarily

I think I would choose whether to use “debug mode” or “C# optimization” depending on the terminology used in the editor preferences window, or change the label in preferences to match with this dialog.

Yes.

https://docs.unity3d.com/2020.1/Documentation/ScriptReference/Compilation.CompilationPipeline-codeOptimization.html
https://docs.unity3d.com/2020.1/Documentation/ScriptReference/Compilation.CompilationPipeline-codeOptimizationChanged.html

Related APIs:
https://docs.unity3d.com/2020.1/Documentation/ScriptReference/Compilation.CompilationPipeline.RequestScriptCompilation.html
https://docs.unity3d.com/ScriptReference/EditorUtility.RequestScriptReload.html

Commandline options have also been added to startup with a specific code optimzation:

-debugCodeOptimization
-releaseCodeOptimization

https://docs.unity3d.com/2020.1/Documentation/Manual/CommandLineArguments.html

Edit: Fixed and added links

1 Like

I think “Set debug mode as default” or “Start in debug mode by default” is clearer than “Switch to debug mode permanently”. The latter conveys that I can’t switch back and that’s not true.
“Switch to debug mode for all sessions” is the most unclear in my opinion.

2 Likes

Here is a new suggestion for the dialog/buttons, let us know what you think :slight_smile:

5 Likes

That looks way better.

Contains all the necessary information and functionality. It’s fine.

1 Like

It’s blessed by QA Jesus, you literally can’t go wrong with it

4 Likes

It would also be nice if I could enable debug mode by clicking on this bug icon down there:

5901398--629795--upload_2020-5-26_18-18-27.png

Right now clicking on it does nothing.

If I click on the icon, a new window appears where I can enable debug mode. See at 6:40 here.

(Case 1250792) Cannot enable debug mode when Unity is maximized on the second monitor

Bug Description

  1. What happened

Clicking on the “bug icon” on the status bar doesn’t display the window that is used to switch between debug and release editor mode.

  1. How we can reproduce it using the example you attached

This is reproducible in an empty project

Test this on a computer with 2 monitors. (Both of my monitors have 100% scaling)
Make sure that the secondary monitor is to the LEFT of the primary monitor.
If the secondary monitor has taskbar enabled, make sure it is NOT docked to the right edge.

Maximize Unity on the secondary monitor
Click on the Debug icon.
The popup window doesn’t appear

  1. More information

The issue is reproducible without maximize as well.
If the debug icon is close to the right edge of the secondary monitor the popup does not appear.
The threshold distance is slightly larger than the with of the 4 icons combined.

This issue also reproducible in 2020.2.0a11

3 Likes