我想請教各位大神:
我想將當前時間寫入我的csv檔裡
目前我可以在我的安卓手機創立csv檔,以及在unity上打進數據,並顯示在csv,
但是我需要的是他自動將時間記錄起來, 每過一分鐘,時間自動在csv的列裡,這要用什麼語法,或是怎麼做法?
當前時間我也有存在一個字串裡了
圖片的excel,是我自己做的,就是我想做成的樣子
感謝大神
下圖是我android裡的csv的資料了,除了表頭是我自行輸入的,時間都沒有在上面
这就是文件IO啊,你随便找个unity CSV文件读写的帖子跟着做就行,时间可以通过Time类获取
這個是我目前做出來的結果
以下是我 WriteCSV的代碼
// 将DataTable中数据写入到CSV文件中
public void WriteCSV()
{
if (myPlayerList.player.Length>0)
{
TextWriter tw = new StreamWriter(filename, false);
StringWriter sw = new StringWriter();
tw.WriteLine("Time,FSR1,FSR2,FSR3");//列頭
tw.Close();
tw = new StreamWriter(filename, true);
sw = new StringWriter();
for (int i = 0; i < 100; i++)
{
sw.WriteLine(myPlayerList.player[i].time + ",");
tw.WriteLine(myPlayerList.player[i].fsr1 + "," + myPlayerList.player[i].fsr2 + "," + myPlayerList.player[i].fsr3);
//tw.WriteLine(myPlayerList.player[i].time + "," + myPlayerList.player[i].fsr1 + "," + myPlayerList.player[i].fsr2 + "," + myPlayerList.player[i].fsr3);
}
tw.Close();
}