Skip to content

Instantly share code, notes, and snippets.

@Naphier
Created October 11, 2015 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Naphier/efabcd1cc27948d818a6 to your computer and use it in GitHub Desktop.
Save Naphier/efabcd1cc27948d818a6 to your computer and use it in GitHub Desktop.
Simple debugging to file. Useful for creating CSV files where you want to look at variable changes over each frame.
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace NG
{
public class DebugToFile
{
public static List<string> dOut = new List<string>();
public static void WriteToLog(string fileName)
{
using (StreamWriter sw = new StreamWriter(Application.dataPath + "/" + fileName))
{
foreach (string s in dOut)
{
sw.WriteLine(s);
}
}
}
public static void WriteToLog()
{
WriteToLog("output.csv");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment