The project encountered the need to read the contents of the DAT files in the situation, let me encounter problems and solutions to summarize ~
The XML was previously loaded with Textasset, but Textasset does not support the. dat file t_t
The file types supported by Textasset are as follows:
- . txt
- . html
- . htm
- . xml
- . bytes
- . JSON
- . csv
- . Yaml
- . fnt
See the official note for details:
Http://docs.unity3d.com/550/Documentation/Manual/class-TextAsset.html
Search for a keyword in bing (degrees Niang not to force), finally found a solution, refer to the link:
Http://answers.unity3d.com/questions/181172/dat-file-location.html
This is the class to use:StreamReader, for reading data, the corresponding write data class is StreamWriter
Specifically, this is done by:
Application.datapath is the project path, strFolderName is the folder name, strFileName is the file name
StreamReader reader = new StreamReader (application.datapath+strfoldername+strfilename);
Convert to String
String strall = reader. ReadToEnd ();
Then you can get what you need from the string ~ ~
Unity3d Loading of text content in DAT files