Home > Enterprise >  Create a list from the debug.log menu
Create a list from the debug.log menu

Time:11-01

I was thinking like public static List<string> debug = new list<string>(); debug.add("debug.log menu item 1"); But I don't know how to do this van someone help

Nothing I have tried has worked Nobody has anything that works

CodePudding user response:

If you mean you want to keep track of any logged messages you can attach a listener to e.g. Application.logMessageReceivedThreaded

private List<string> logs = new List<string>();

// Start is called before the first frame update
private void Awake()
{
    Application.logMessageReceivedThreaded  = HandleLog;
}

private void OnDestroy()
{
    Application.logMessageReceivedThreaded -= HandleLog;
}

private void HandleLog(string content, string stacktrace, LogType type)
{
    logs.Add($"{type} - {content}\n{stacktrace}");
}

Obviously this will not allow to access any logs previous to attaching the listener ;)

  • Related