Playmaker Forum

PlayMaker News => General Discussion => Topic started by: mrminico on January 12, 2023, 04:48:40 AM

Title: Get Console log action but for Unity errors
Post by: mrminico on January 12, 2023, 04:48:40 AM
Does anyone know of an action that can get unity Console logs and save it into a string?

Example: there's an error on Unity's end I'll be able to get the log and plug it into a string to see it in-game. 
Title: Re: Get Console log action but for Unity errors
Post by: djaydino on January 12, 2023, 11:31:17 AM
Hi.
I did a quick search and with C# script it seems not to be possible.
If its not possible in C# then it will also not be possible with an action :)

if you overlooked and it is possible in C#, then post a link :)
Title: Re: Get Console log action but for Unity errors
Post by: mrminico on January 27, 2023, 05:47:31 PM
I actually found a way to do it. A combination of both Scripts and Playmaker

public class DebugLog : MonoBehaviour
{
    public string log;

    private void Start()
    {
        log = "";
        Application.logMessageReceived += HandleLog;
    }

    private void HandleLog(string logString, string stackTrace, LogType type)
    {
        log += logString + "\n";
    }
}


And then I used Get Property Action set the Target Object to Debug Script and Property to Log. I then stored the string and set the UI to show me the results.
Title: Re: Get Console log action but for Unity errors
Post by: djaydino on January 28, 2023, 10:06:32 AM
Hi.
Oh nice!

Does it work in a build?
Title: Re: Get Console log action but for Unity errors
Post by: mrminico on January 30, 2023, 02:59:42 PM
Yes, it worked on the build and displayed the console information through the string I stored.