Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Wrong values shown in Visual Studio debugger

Discussion in 'Scripting' started by DrabaL, Feb 19, 2018.

  1. DrabaL

    DrabaL

    Joined:
    Jan 4, 2018
    Posts:
    6
    I'm assigning a value to a locally created Vector3's x, y, and z components.
    My problem is that the debugger reports wrong values for the vector, even directly after the assignment.

    Added a watch to the expressions creating the values, they are correct both before and after using them.
    The debugger is definitely wrong since the code using the vector works fine.
    If I set the components to a constant instead of the expression they report the correct values.
    Not tied to Vector3's, that was just the most recent example. This is inside a FixedUpdate, no other threads interfering.

    Tried:
    - removing the bin folders, cleaning/rebuilding
    - disabling JIT optimization
    - switching between VS2017 and 2015
    - switching between Unity 2017.3 and 2018.1 beta
    - creating a new project from scratch and adding some scripts again

    I hope I'm just missing something trivial, anyone has a guess what could be the problem?
     
    Last edited: Feb 20, 2018
  2. DrabaL

    DrabaL

    Joined:
    Jan 4, 2018
    Posts:
    6
  3. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    Have you tried re-installing the VSTU plugin? Or use the nuclear option of re-installing both Unity and VS2017. That's about all I can think of; something must've gotten corrupted somewhere.

    I use the debugger a lot and it works fine for me, so I'm not sure what else to say.
     
  4. DrabaL

    DrabaL

    Joined:
    Jan 4, 2018
    Posts:
    6
    I did full reinstalls and tried different versions of both Unity(2017.3 and beta 2018.1) and Visual Studio(2015 and 2017), neither worked.
    The debugger does work fine on a fresh win 10 on another computer so something deeper is borked on my current one or I just ran into a rare issue with win 8.1.
    Spent way too much time on this problem already so will just nuke the OS on the machine I use for Unity and stop worrying about the cause.
     
  5. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    It sounds like the .NET framework somehow got corrupted on your Win8.1 machine. But yes... I agree, a fresh OS re-install would likely be faster than trying to figure out the underlying cause (which may be uninstalling all .NET frameworks, re-install, and hope that fixes the problem...)
     
  6. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,589
    Unity's Vector3.ToString method rounds the vector components, which makes the debugger appear to display wrong values, if you refer to that behavior? The vector components should be displayed correctly if you expand the vector in the Watch window.
     
  7. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    Going by the last screenshot, 5.24f is somehow being rounded up into 22, so there's something fishy about that.