Unity3d Loading of text content in DAT files

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.