How to read the third line (instance reference) of the console in script?

I’m trying to read out the console through script, and while getting the first line (condition) and the second one (stackTrace) is super simple, I can’t figure out how to get the third one, the one that tells me which objects led to triggering the actual event. Any tips?

    private void OnEnable()
    {
        Application.logMessageReceived += AddConsoleText;
    }
   

    private void AddConsoleText(string condition, string stackTrace, LogType type)
    {
        if (type == LogType.Warning) return;

        conditionText = condition;
        stackTraceText = stackTrace;
    }

The first line is the message, the second line appears to be the .ToString() of the context, or perhaps of a summary of the original log call, and the third line (and beyond) in the above graphic is the stack trace.

I don’t think you would ever get the context itself at runtime, since that could conceivably be just an asset on disk or a transient object in memory such as a component in scene.

I think the clickability of the context exists only in the editor window(s).

This code:

        Debug.Log("Tweedle");
        Debug.Log("Dee", this);

produces:

8411253--1111515--Screen Shot 2022-09-02 at 12.29.58 PM.png

1 Like