Search Unity

Debugging: unable to follow variables

Discussion in 'Scripting' started by yvaing, Feb 17, 2019.

  1. yvaing

    yvaing

    Joined:
    Feb 5, 2019
    Posts:
    3
    Hello,

    Using Visual Studio, I launch and test my scripts using "Attach to Unity and play". I ran onto a nell exception error, got the line and the class name on the Unity debug log, but after double clicking on the error on Unity, I am not able to check the values of the variables and objects on Visual Studio. Weirdly, it's working fine when usng bullet points, but it would be really useful when I get errors...
    Am I missing something?

    Thanks!
     
  2. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    In Visual Studio the variables are normally only visible in the 'scope' of the function you're looking at. If you hit ctrl-alt-c (I think) to open the call stack window you can select the calling function and view the variables within that.
     
  3. yvaing

    yvaing

    Joined:
    Feb 5, 2019
    Posts:
    3
    Actually, the problem is that Visual Studio doesn't seem to catch anything unless I use a break point. WHen I double click on the error on Unity, Visual Studios just points to the line on the right script, but doesn't get the error.

     
  4. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
  5. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    As far as I can remember, breaking on exceptions is no enabled by default. Look through the debug settings in VS, there should be somewhere you can enter eg. NullReferenceExceptions as something VS breaks on.
     
  6. FernandoHC

    FernandoHC

    Joined:
    Feb 6, 2018
    Posts:
    338
    What you have there is a runtime exception, as far as I know, even in debug mode, visual studio will only display compile time exceptions in the log.
    You will have to rely on unity logs for runtime issues.

    Also, you're looking at the wrong windows, You should be looking at the Error window, accessible through View->Error List or Output(console).
     
  7. yvaing

    yvaing

    Joined:
    Feb 5, 2019
    Posts:
    3
    Thanks for the answers! I've found what I need, I am going to play with that.