Question by
Numenization · Aug 17, 2017 at 07:22 PM ·
c#buildapplicationversion
Application.logMessageReceived doesn't appear to be working in build version?
I'm trying to make an ingame debug console using UI components so that I can pinpoint problems that may only be present in the build version of my game. But I'm running into just that sort of issue... Application.logMessageReceived and Application.logMessageReceivedThreaded work perfectly fine in the editor, but don't appear to be working at all in the build version of my game.
Here's the relevant code that I'm using:
private void OnEnable()
{
Application.logMessageReceivedThreaded += HandleLog;
}
private void OnDisable()
{
Application.logMessageReceivedThreaded -= HandleLog;
}
void HandleLog(string logString, string stackTrace, LogType type)
{
message = logString;
stacktrace = stackTrace;
LogToConsole(logString, stackTrace, type);
}
public static void LogToConsole(string logString, string stackTrace, LogType type)
{
GameObject textLine = Instantiate(new GameObject("DebugTextLine"), contentPanel.transform);
RectTransform rectTransform = textLine.AddComponent<RectTransform>();
Text text = textLine.AddComponent<Text>();
ContentSizeFitter fitter = textLine.AddComponent<ContentSizeFitter>();
fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
fitter.horizontalFit = ContentSizeFitter.FitMode.Unconstrained;
text.font = consolasFont;
switch (type)
{
case LogType.Log:
text.color = Color.white;
break;
case LogType.Warning:
text.color = Color.yellow;
break;
case LogType.Error:
text.color = Color.red;
break;
default:
text.color = Color.cyan;
break;
}
text.text = "<b>" + logString + "</b>\n<size=11>" + stackTrace.Substring(0, stackTrace.Length - 1) + "</size>";
rectTransform.anchorMin = new Vector2(0.01f, 0.01f);
rectTransform.anchorMax = new Vector2(0.01f, 0.01f);
rectTransform.pivot = new Vector2(0.5f, 0);
float width = contentRect.rect.width;
float height = rectTransform.rect.height;
rectTransform.offsetMin = new Vector2(0, 0);
rectTransform.offsetMax = new Vector2(width, height);
UpdateList(rectTransform);
lineList.Insert(0, textLine);
}
I've tested LogToConsole by itself in the build version and that works fine. Anyone have any ideas?
Comment