I’ve tried every solution out there, but Application.RegisterLogCallback does not seem to work.
I know it was bugged in the past, is it bugged again?
Any help here would be great since unity is slooooooooooooooow to respond to bug reports.
http://docs.unity3d.com/Documentation/ScriptReference/Application.RegisterLogCallback.html
Here’s how I used it before and it worked ok.
public class SomeInitializingScript : MonoBehaviour
{
void Start()
{
Application.RegisterLogCallback(Logger.Instance.Log);
}
}
public class Logger
{
private static Logger instance = null;
public Logger() { // initialize your logger here }
public static Logger Instance
{
get
{
if (instance == null)
instance = new Logger();
return instance;
}
}
public void Log(string text, string stackTrace, LogType type)
{
// handle log entry here
}
}
Thanks for the feedback.
Sadly, still nothing. I can’t get the Log() method to fire off.
-R
I just tested this and this code works for me. I can see the logged text in the variable in the inspector.
public string message;
void Start(){
Application.RegisterLogCallback(Log);
Debug.Log("Test");
}
public void Log(string text, string stackTrace, LogType type)
{
message = text;
}
Is it possible you are using RegisterLogCallback() from more than one location, and the other location is taking precedence?
It’s so strange, but I can’t get it to work. I’ll check my project for other places it may be registered.
Alright, so UnityWeb comes with a demo class that does use RegisterLogCallback(), but I commented it out and I’m left with:
void Start(){
Application.RegisterLogCallback(Log);
Debug.LogError("WARNING");
}
public void Log(string text, string stackTrace, LogType logType){
Debug.Log(text + " " + stackTrace);
}
But nothing. It’s active, because it does log Warning, but I’m not getting the log from Log().
EDIT: Ok, well I guess it makes sense (but I didn’t think of it): you can’t directly log the output , you have to save it to a string first. Arterie’s suggestion works, in the sense that I can see the public string in the editor. Thanks for the help, everyone.