Search Unity

How to find components you don't have a reference to during a debug breakpoint?

Discussion in 'Editor & General Support' started by s_guy, Apr 26, 2019.

  1. s_guy

    s_guy

    Joined:
    Feb 27, 2013
    Posts:
    102
    Say you capture a bug at runtime with a debugger attached. You suspect the issue lies in a component that you don't have a reference to in code. What can you do aside of adding more hooks in code and trying to recapture the bug?

    Essentially I want to navigate through MonoBehaviors of a GameObject without having a code reference ahead of time. That is, I want to GetComponent<type>() at debug time and investigate it.

    I'm using Visual Studio.

    Thanks!
     
  2. JokeOfAllTrades

    JokeOfAllTrades

    Joined:
    Mar 11, 2014
    Posts:
    1
    I'm not sure if you figured this out, so I'm answering for people who have this issue in the future. It's not a perfect solution, but I believe it will give you what you are looking for. It used to be that in the VS debugger, you could see the state of gameobject.component. My work around is to create a watch for gameobject.GetComponent<componentType>(). This allowed me to see everything I needed about the component in question. Hope this helps.