- Home /
Trace which line of a script called a particular function
is there a way to do a backtrace on which line of the script called a particular function?
you asked 3 questions in 10 $$anonymous$$utes? That's very productive. LoL
wow, I just cheked you have asked 247 questions so far. Now UnityAnswers has 23,724 questions in total which means 1% of them is asked by YOU. applaud
asking questions is how i learn. google can only work so much. please feel free to answer if you have knowledge to share.
Answer by loramaru · May 09, 2011 at 07:58 AM
Hopefully this will suit your needs.
Debug.Log(System.Environment.StackTrace);
Answer by CHPedersen · May 09, 2011 at 08:02 AM
The way to do that is to use a standard debugging tool and set breakpoints, then execute each statement one by one to follow the code's control flow in in your editor. This isn't possible with Visual Studio however, since Unity uses Mono and therefore can't attach to Visual Studio's debugger, but perhaps it's possible with Mono Develop, I've never used that as an editor for unity.
As a lowtech alternative, you could simply insert strategic Debug.Log calls to see what gets called and what doesn't...
can you suggest some standard debugging tools that'd do what you said for unity ... the debug.log only goes so far and doesn't go recursively to indicate which function called which
It seems $$anonymous$$ono Develop does have a standard debugger. Take a look at http://www.mono-project.com/Debugger. Unity ships with mono develop and uses its runtime system, so it should attach to $$anonymous$$ono Develop's debugger, too.
Your answer
Follow this Question
Related Questions
Unity Alert or Trace 2 Answers
DEBUG;TRACE; Compile Problems 1 Answer
Unity 2017 frame rate capped? 2 Answers
Can I see debug log(ex:printf) from C++ dll in Unity? 0 Answers
Unity crashes without debugging 0 Answers