- Home /
How to write debug log to txt file?
Hi,
I am using a visual scripting language (playmaker) to continuously track distance between two objects and save those values in a float variable. Now I want to debug that float variable and output the debug log to a txt file. Could someone help me in doing so? (please keep in mind I am a n00b and have no prior coding experience smile )
If possible can someone tell me where I need to insert what code exactly for this to work?
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Debug)]
[Tooltip("Logs the value of a Float Variable in the PlayMaker Log Window.")]
public class DebugFloat : BaseLogAction
{
[Tooltip("Info, Warning, or Error.")]
public LogLevel logLevel;
[UIHint(UIHint.Variable)]
[Tooltip("The Float variable to debug.")]
public FsmFloat floatVariable;
public override void Reset()
{
logLevel = LogLevel.Info;
floatVariable = null;
base.Reset();
}
public override void OnEnter()
{
string text = "None";
if (!floatVariable.IsNone)
{
text = floatVariable.Name + ": " + floatVariable.Value;
}
ActionHelpers.DebugLog(Fsm, logLevel, text, sendToUnityLog);
Finish();
}
}
}
Answer by Jessespike · Sep 16, 2016 at 08:13 PM
There are log callbacks that can be used.
https://docs.unity3d.com/ScriptReference/Application.LogCallback.html
And combine it with writing to a text file
Here's an example, it uses RegisterLogCallback which doesn't exist anymore I think. But you can still learn from example.
http://answers.unity3d.com/questions/416675/get-debuglog-output-in-the-working-ios-build.html
More links
Answer by Arkins_prod_studio · Sep 16, 2016 at 08:28 PM
I made this on this question: http://answers.unity3d.com/questions/1243076/how-to-make-a-level-blockunblock.html I hope you'll find what you search :)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to use #define to turn debug information on/off 1 Answer
How to get the colliders working? 1 Answer
Make a method that returns a string from a text document. 2 Answers