How to Unity3D – Use VisualStudio Script Editor and Debug Project

unity-logoIn this tutorial, you’ll see a project configured with VisualStudio. And how to run and debug it.

ScreenShot034.png

Steps

  1. Open the ‘Example’ project
  2. Choose a Script Editor
  3. Add breakpoint in source code
  4. Attach Script Editor to Unity3D
  5. Debug

1. Open the ‘Example’ project

In Unity3D:

  • Projects > Open > ‘Example’ > (wait) > Open Scene > ‘Sample Scenes Scenes/car.unity’
  • Edit > Play > (test it) > Play (or click Play button, or press Ctrl+P)

screenshot0058.png

ScreenShot009.png

ScreenShot002

ScreenShot003

ScreenShot004

ScreenShot010

ScreenShot011

ScreenShot012

2. Choose a Script Editor

In Unity3d:

  • Edit > Preferences > External Tools > ExternalScriptEditor: ‘MonoDevelop’
  • Assets > Open C# Project

ScreenShot005

ScreenShot021.png

ScreenShot007.png

ScreenShot022

3. Add Breakpoint in source code

In VisualStudio:

  • Open ‘SampleScenes/Menu/Scripts/MenuSceneLoader.cs’
  • Add a breakpoint to line 14

ScreenShot025.png

4. Attach Script Editor to Unity3D

In VisualStudio:

  • Click the little show button next to ‘Attach to Unity’ > Select ‘Attach to Unity and Play’

ScreenShot023

5. Debug

In VisualStudio:

  • Click ‘Attach to Unity and Play’
  • (it’s in pause now, stopped at the breakpoint line)
  • Click Continue (or press F5)

In Unity3d:

  • (play with it)

In VisualStudio:

  • Click Stop (or press Shift+F5)

ScreenShot024

ScreenShot026

ScreenShot028

ScreenShot029

ScreenShot030.png


Conclusion

Pros: More productive than MonoDevelop  (you don’t have to switch beetwen Editor and Unity3D to run a debug). Dark Them is nice too!

Cons: More heavy on CPU/RAM than MonoDevelop. And it’s a Microsoft product 😉

 

Here is the same project opened on VisualStudio, MonoDevelop and a text Editor.

resources.png

 

Source

https://github.com/DamienFremont/blog/tree/master/20170603-unity3d-use-visualstudio-script-editor-and-debug/

References

https://unity3d.com/fr/learn/tutorials/topics/scripting/debugging-unity-games-visual-studio

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s