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. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Excluding a method frame from stack trace in Debug.Log()?

Discussion in 'Scripting' started by frosted, Jul 29, 2014.

  1. frosted


    Jan 17, 2014
    Is there any way to do this?

    The use case is stuff like a throw helper, where you toss an exception or log item from some method but you don't want that call to show up in the stack trace.

    Here's another example:
    Code (csharp):
    2. public static class GameObjExtension{
    3.   public static void Log( this MonoBehaviour mono, String msg ){
    4.     Debug.Log( + ":" + msg );
    5.   }
    6. }
    8. .... usage like:
    9. public class ABC : MonoBehaviour{
    10.   public void Awake(){
    11.    this.Log( "include my game object's name in the log automatically" );
    12.   }
    13. }
    But when you click the log item in the editor, it would jump to ABC's Awake call not GameObjExtension.

    Is there like a MethodImpl tag or something tricky and hidden?
  2. Graham-Dunnett


    Unity Technologies

    Jun 2, 2009