using System.IO;

     //test read txt
        //Resources.Load(...) loads an asset stored at path in a Resources folder.
        //ref: http://docs.unity3d.com/Manual/class-TextAsset.html
        //ref: http://forum.unity3d.com/threads/read-text-file-that-is-included-in-the-project.189649/
        //ref: http://www.mindthecube.com/blog/2009/11/reading-text-data-into-a-unity-game
        //ref: http://www.unitymanual.com/6072.html  

TextAsset textAsset = (TextAsset)Resources.Load("readme", typeof(TextAsset));
        if (textAsset==null) {
            Debug.Log("text file not found");
        } else {
            StringReader reader = new StringReader(textAsset.text);
            if ( reader == null )
            {
                Debug.Log("text file not readable");
            }
            else
            {
                // Read each line from the file
                string str;
                while ( (str = reader.ReadLine()) != null ){
                    Debug.Log("-->" + str);
                }
            }

}

readme.txt放在Assets/Resources路径下。

unity, read text file的更多相关文章

  1. shell脚本执行时报"bad interpreter: Text file busy"的解决方法

    在执行一个shell脚本时,遇到了“-bash: ./killSession.sh: /bin/bash: bad interpreter: Text file busy”错误提示,如下所示: [or ...

  2. Unity: Invalid serialized file version xxx Expected version: 5.3.4f1. Actual version: 5.3.5f1.

    Unity发布安卓项目,如果直接使用Unity打包APK一切Ok,导出Google项目 使用Idea打包 一进去直接Crash. 报错: 1978-2010/? E/Unity﹕ Invalid se ...

  3. eclipse的使用-------Text File Encoding没有GBK选项的设置

    eclipse的使用-------Text File Encoding没有GBK选项的设置 2013-12-25 09:48:06 标签:java myeclipse使用 有一个项目是使用GBK编码的 ...

  4. Writing Text File From A Tabular Block In Oracle Forms

    The example given below for writing text file or CSV using Text_IO package from a tabular block in O ...

  5. create feature from text file

    '''---------------------------------------------------------------------------------- Tool Name: Cre ...

  6. The 12th tip of DB Query Analyzer, powerful in text file process

    MA Gen feng ( Guangdong Unitoll Services incorporated, Guangzhou 510300) Abstract   It's very powerf ...

  7. 【转】shell脚本执行时报"bad interpreter: Text file busy"的解决方法

    1)问题现象: 在ubuntu下执行以下脚本( while_count),报错: -bash: ./while_count: /bin/bash: bad interpreter: Text file ...

  8. New text file line delimiter

    Window -> Preferences -> General -> Workspace : Text file encoding :Default : 选择此项将设定文件为系统默 ...

  9. [转]How to Import a Text File into SQL Server 2012

    Importing a using the OpenRowSet() Function The OPENROWSET bulk row set provider is accessed by call ...

随机推荐

  1. mysqldumper

    介绍 MySQL自身的mysqldump工具支持单线程工作,依次一个个导出多个表,没有一个并行的机,这就使得它无法迅速的备份数据. mydumper作为一个实用工具,能够良好支持多线程工作,可以并行的 ...

  2. Android内存优化10 内存泄漏常见情况1 静态泄漏

    1,内存泄漏到本质是该释放的对象被持久化的对象引用了,造成持久化的常见情况有1,静态持久化 2,线程持久化 线程持久化 因为存活的线程是有dvk虚拟久直接持有,所以存活的线程都是持久化的 内存泄漏1: ...

  3. 一份不太简短的LaTeX教程 lshort – A short in­tro­duc­tion to LATEX 2elshort – A short in­tro­duc­tion to LATEX 2e

    Lshort started as a trans­la­tion and ra­tio­nal­i­sa­tion of a ground-break­ing Ger­man-lan­guage i ...

  4. fiddler在ios10.3系统抓包https失败原因解决

    一直是按照以往的设置抓包,设置代理ip,通过Safari下载安装证书,抓包https怎么显示证书无效呢?难道证书被apple设为黑名单了?google后发现,IOS10.3以后,安装了证书不是默认启用 ...

  5. What is required for a successful backup of all files during hoi backup?

    There is a typo in the body of this question. It should be "Hot" instead of "hoi" ...

  6. 在移动网页网页上点击链接跳转到QQ聊天界面

    打开qq聊天窗口的方法 <a href="http://wpa.qq.com/msgrd?v=3&uin=1450612626&site=qq&menu=yes ...

  7. MyEclipse 2014配置Maven

    1 配置maven (1)下载apache-maven-3.3.3和mvnRespo放在某个路径下,我这里是放在D盘根目录下. (2)修改D:\apache-maven-3.3.3\conf\sett ...

  8. 桌面轻量级数据库的选择:Access、SQLite、自己编写?

    1. Access我们做小项目的时候特别是小的MIS系统一般也都要用数据库来保存数据.经观察大部分的小系统都是用Access数据库,有的系统为了掩盖数据库的类型,把数据文件后缀名改了,其实只要改回到m ...

  9. Fedora 中的容器技术:systemd-nspawn

    本文将说明你可以怎样使用 Fedora 中各种可用的容器技术和学习“systemd-nspawn”的相关知识. 容器是什么? 一个容器就是一个用户空间实例,它能够在与托管容器的系统(叫做宿主系统)相隔 ...

  10. java 注解(自身理解)

    声明注解 使用注解 解析注解 产生的结果 注解利用的是反射机制 ============================================================= 使用注解修饰 ...