"unity read text file" Code Answer's
You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "unity read text file" answered properly. Developers are finding an appropriate answer about unity read text file related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like unity read text file. Enter your desired code related query in the search bar and get every piece of information about C# code related question on unity read text file.
unity read from text file
using UnityEngine;
using UnityEditor;
using System.IO;
public class HandleTextFile
{
[MenuItem("Tools/Write file")]
static void WriteString()
{
string path = "Assets/Resources/test.txt";
//Write some text to the test.txt file
StreamWriter writer = new StreamWriter(path, true);
writer.WriteLine("Test");
writer.Close();
//Re-import the file to update the reference in the editor
AssetDatabase.ImportAsset(path);
TextAsset asset = Resources.Load("test");
//Print the text from the file
Debug.Log(asset.text);
}
[MenuItem("Tools/Read file")]
static void ReadString()
{
string path = "Assets/Resources/test.txt";
//Read the text from directly from the test.txt file
StreamReader reader = new StreamReader(path);
Debug.Log(reader.ReadToEnd());
reader.Close();
}
}
Source: support.unity.com
All those coders who are working on the C# based application and are stuck on unity read text file can get a collection of related answers to their query. Programmers need to enter their query on unity read text file related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about unity read text file for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of unity read text file while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "unity read text file". Visit this developer's friendly online web community, CodeProZone, and get your queries like unity read text file resolved professionally and stay updated to the latest C# updates.