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. Dismiss Notice

Is it possible to change where in the codebase is highlighted when double-clicking on a console log?

Discussion in 'Editor & General Support' started by Lucas-Hehir, Jul 25, 2018.

  1. Lucas-Hehir

    Lucas-Hehir

    Joined:
    Jul 2, 2014
    Posts:
    41
    I have a generic 'behaviour' wrapper class that I use in scripting for a couple of reasons, one of the main ones being debugging. In this class, I have my own wrapper functions for Debug.Log, Debug.Warning and Debug.Error and a debug state enum so I can control when debug messages appear on a per-object basis. It looks something like this:

    Code (CSharp):
    1. public class WrapperBehaviour : MonoBehaviour {
    2.  
    3.     public DebugState localDebugState;
    4.  
    5.     public void Log(GameObject sender, string message) {
    6.         if (localDebugState == DebugState.LogsOnly || localDebugState == DebugState.All) {
    7.             Debug.Log(message, sender);
    8.         }
    9.     }
    10. }
    However, I've noticed that when I double click a message in the Editor console, it takes me to the actual occurrence of Debug.Log/Warning/Error, rather than the place where the Log/Warning/Error method occurs. It makes sense, but is it possible to change it so that double-clicking brings up the place where Log/Warning/Error is originally called instead?
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,444
    If you store the Debug.Log wrapper in a DLL, a double-click forwards you to the caller, rather than to your own Log implementation.
     
    Last edited: Apr 4, 2023
    joveem_ and _eternal like this.
  3. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    More of a workaround than a solution, but the Console Enhanced asset has the ability to add custom wrapper functions that will be skipped when going to the source file.
     
  4. Lucas-Hehir

    Lucas-Hehir

    Joined:
    Jul 2, 2014
    Posts:
    41
    Unreal, this is a great solution. Thanks a tonne!
     
    joveem_, Thimo_ and Peter77 like this.
  5. JaredThomson

    JaredThomson

    Joined:
    Nov 15, 2013
    Posts:
    16
    Just wanted to add a note for anyone reading: using an assembly definition will not accomplish the same thing.
     
    joveem_ and Lucas-Hehir like this.
  6. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    264
    It took me some time to figure out how to do this in Visual Studio 2022 + Unity 2021, so I'll just leave the current instructions here: https://docs.unity3d.com/Manual/UsingDLL.html

    When I tried to create the project in VS, I had to click install more tools and features and then install the .NET Desktop Development workload. Also, the project template for me is called Class Library (.NET Framework) as opposed to Class Library (.NET Standard).

    Besides that, the only other thing I did was navigate to Project -> <ProjectName> Properties and change Target Framework to .NET Framework 4. The rest of the instructions worked correctly, as far as I can tell.
     
  7. DF3Boris

    DF3Boris

    Joined:
    May 2, 2023
    Posts:
    2
    Heya! Reviving this.

    Currently encountering the same problem as in the original post, even though the wrapper functions are already in a DLL. Double-clicking the logs in the console brings me to the function definition in the DLL.

    Any idea as to what might be happening?
     
    Last edited: May 29, 2023