Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Debugging in VS Code using the dotBunny plugin

Discussion in 'Scripting' started by ashishchandy, Jan 18, 2016.

  1. ashishchandy

    ashishchandy

    Joined:
    Jan 18, 2016
    Posts:
    7
    I am unable to view Debug.Log messages in the VS Code Debug Console

    The plugin is integrated the files are opening in VS, intellisense is also working.

    The plugin is from here
    https://github.com/dotBunny/VSCode/

    I hit the green play buttton on VSCode then the Play button on unity
    Is there some other function to debug via VS ,I am fairly new to this.
    Please help

    Im on
    OS X 10.11.1
    Unity 5.3.1
    Mono JIT compiler version 4.2.1
    VS Code Version 0.10.6 (0.10.6)



    Screen Shot 2016-01-19 at 2.37.51 AM (2).png
     
  2. Teravisor

    Teravisor

    Joined:
    Dec 29, 2014
    Posts:
    654
    Debug with VS has several features you need to remember:
    1. You can't debug code that belongs to unity. It starts in it so you can't use debug before unity's code gets to your script.
    2. The main point of debugging is place a breakpoint and watch what happens after by stepping by one command(default should be F9 to place/remove breakpoint, F10 and F11 for step over/into unless OS X VS has different keys). More to it: because of point 1 unless you place breakpoint there's no other way to stop execution. On screenshot I don't see any breakpoints... Basically. you didn't tell VS where to stop.

    I didn't try it on OS X and I didn't try dotBunny, but those are just basics that are applicable everywhere.

    To check if it is working:
    1. Run VS. Run Unity. (order doesn't matter).
    2. Attach VS debug (windows' F5, don't know OS X) and Place breakpoint on some instruction(I see only Debug.Log(...) where it can stop - so place it there)
    3. Run unity. Now VS should've stopped execution and be on that breakpoint. Unity is 'frozen' and not responding and you can see any variables available in that place in code. That's expected behaviour at least. Then continue or step and be happy. Don't forget to get debugger to continue after it goes off your code or unity will still be hanging 'frozen'.
     
  3. ashishchandy

    ashishchandy

    Joined:
    Jan 18, 2016
    Posts:
    7
    Thanks breakpoints are working I had assumed I would be able to see console messages too and that I missed something during integration.
     
  4. Teravisor

    Teravisor

    Joined:
    Dec 29, 2014
    Posts:
    654
    On my windows+unity+unityVS+VS2015 I have problems with console messages sometimes staying in VS when they shouldn't and not appearing when they should, sometimes they work, sometimes they don't, so... I guess that's a bug, but I don't deem it critical. Breakpoints are better than Debug.Log(...) in all cases except when they don't work.
     
  5. Reapazor

    Reapazor

    Joined:
    Jun 19, 2008
    Posts:
    173
    Try updating the plugin to the latest version, it will now assist in adding in the Unity Debugger backend to Code as well.
     
  6. Ches81

    Ches81

    Joined:
    Nov 27, 2012
    Posts:
    7
    Hey, I recently wrote am article on how to attach VSCode debugger to Unity. It's really easy. You just have to install the Unity Debug extension in VSCode.

    A short tutorial how to set this up can be found here: http://bit.ly/1RuONSq

    A tutorial on how to install and setup VSCode with Unity in general can be found here: http://bit.ly/22s6SsL

    I hope this helps clearing things up for you.