티스토리 뷰

Programming/Unity

unity-debug-with-visual-studio

BaeMinCheon 2019. 1. 20. 13:44

unity-debug-with-visual-studio

  • this post covers how to debug with Visual Studio in Unity
  • environment
    • Windows / 10
    • Unity / 2018.3.0f2
    • Visual Studio / 2015 Professional
    • Game Project / 2D UFO Tutorial

pre-task


  • double click any CSharp script in the project on Unity editor
    • then, Visual Studio with the project gonna be open
  • now, you have Unity editor and Visual Studio open

start-debug

  • there are two ways to starting to debug Unity with Visual Studio


  • way #1
    • click Attach to Unity in Visual Studio
    • click Play in Unity editor


  • way #2
    • change from Attach to Unity to Attach to Unity and Play
    • click Attach to Unity and Play
  • when you follow either of the ways, Unity and Visual Studio are connected
    • and you are ready to debug the game in Visual Studio

break-point

  • it is possible to use breakpoints as usual debugging in Visual Studio

  • I put a breakpoint in the statement for checking whether the if statement works
  • and started debugging as following some way above



  • when player gets an item, game gets paused
    • and the breakpoint in Visual Studio is activated
  • in this situation, you can find which variable has some value from Visual Studio
    • as usual debugging with breakpoint

  • when you wanna resume the game, click Continue in Visual Studio
    • then, the game in Unity editor gets resumed



  • even you can add or remove breakpoint during debugging the game
    • I've removed first breakpoint and added second breakpoint in the statement
    • when player gathers all item, the breakpoint would be activated

precaution

  • when you start debugging following way #2, there is one caution you should be care
    • if you edit some CSharp script in Visual Studio, you should click Unity editor
    • then, Unity detects the changes and compiles your CSharp script into some dlls such as Assembly-CSharp.dll
      (when Unity editor doesn't respond, it does the compilation)
  • in other way, way #1, you will have to click Unity editor
    • so automatically this problem gets solved


'Programming > Unity' 카테고리의 다른 글

unity-hub-usage  (0) 2019.05.26
unity-supporting-various-screen-ratio-with-anchor  (0) 2019.04.19
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함