-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHandleTextFile.cs
More file actions
33 lines (30 loc) · 889 Bytes
/
HandleTextFile.cs
File metadata and controls
33 lines (30 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using UnityEngine;
using System.IO;
public class HandleTextFile
{
static string path = "Assets/LogFile/Log.txt";
static int ID = 1;
public static void WriteString(string s)
{
//Write some text to the test.txt file
StreamWriter writer = new StreamWriter(path, true);
writer.WriteLine(s);
writer.Close();
}
public static void ReadString()
{
//Read the text from directly from the test.txt file
StreamReader reader = new StreamReader(path);
Debug.Log(reader.ReadToEnd());
reader.Close();
}
public static void WriteID()
{
int counter;
counter = PlayerPrefs.GetInt("COUNTER");
Debug.Log("ID: " + counter + "");
WriteString("ID: "+ counter + "");
counter++;
PlayerPrefs.SetInt("COUNTER", counter);
}
}