2

I made a custom Debug.Log using Conditional attribute like this

[Conditional("DEBUG_BUILD"), Conditional("UNITY_EDITOR")]
public static void Print(object str)
{
    UnityEngine.Debug.Log(str);

}

And I use it like this

void Something()
{
    CustomDebug.Print("Error");
}

But when I click the console, It open the custom log script not the script that caused error. I wonder if I can make link the console with error script.

2 Answers 2

2

It's simply returning the last most call in the stack, which is going to be the code in your custom Debug script.

You can get around this easily by compiling this into it's own assembly though, move your code to a Managed Unity DLL, then it will ignore the DLL level stack trace and only return the location your custom method was called from.

Sign up to request clarification or add additional context in comments.

Comments

0

Maybe you can try Application.logMessageReceived to implement your custom debug log.

And you can use UnityEngine.Debug.Log() or MonoBehaviour.print() to record logs. It still can link to the scripts.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.