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. CentOS下OpenVPN实现公网IP映射到内网(iptables转发功能)(转)

    说明:这种方案的实现前提是必须要有一台拥有公网IP的电脑,OpenVPN搭建过程很普通,关键技术在于iptables的转发.搭建教程可能有点旧了,可以只看iptables的关键点技术. 方案背景: 公 ...

  2. 两篇整合Activiti Modeler到业务系统

    1. 无法进入editor. http://localhost:8080/YouPRJ/modeler/service/editor?id=2050,前提是这个id必需存在与act_re_model表 ...

  3. maven本地仓库地址的设置

    对于大公司的jenkins来说,仓库是很大的,那么存储仓库的目录空间一定要足够大才可以. 可以对linux进行外挂,实现磁盘扩容,把仓库挂在外挂上. 默认情况下,mvn的配置文件在~/.m2/sett ...

  4. java界面编程(3) ------ 控制布局

    本文是自己学习所做笔记,欢迎转载,但请注明出处:http://blog.csdn.net/jesson20121020 在java 中,组件放置在窗口上的方式可能与其它的GUI系统都不同样.首先,它全 ...

  5. Delphi中Frame的使用方法(2)

    Frame在写代码时和一般组件有什么不同呢?比如(1)中的客户信息的frame,如果想重写客户编辑按钮的click事件,会发生什么呢: procedure TBusOnSiteManager.Fram ...

  6. Walle代码发布系统

    Walle 一个web部署系统工具,配置简单.功能完善.界面流畅.开箱即用!支持git.svn版本管理,支持各种web代码发布,PHP,Python,JAVA等代码的发布.回滚,可以通过web来一键完 ...

  7. Win8安装程序出现2502、2503错误解决方法

    我是在安装VMware virtualbox的时候遇到的这个问题,上网百度了一下发现这是个在win8系统上安装程序时才会遇到的. 究其原因这个问题还是由于权限问题导致的,解决方法如下: 1,ctrl+ ...

  8. 配置到 Framework GAC(Global Assembly Cache) Assembly

    配置到 Framework 通常有两种方法,一种是直接把它放到GAC(Global Assembly Cache作用是可以存放一些有很多程序都要用到的公共Assembly)中 :另一种是把它们放到具体 ...

  9. Node.js abaike图片批量下载Node.js爬虫1.01版

    //====================================================== // abaike图片批量下载Node.js爬虫1.01 // 1.01 修正了输出目 ...

  10. 倍福TwinCAT(贝福Beckhoff)常见问题(FAQ)-有时候项目会无法编译,重新生成就自动卡死或者自动退出怎么办

    删除所有中文注释,有中文注释则不一定能编译成功.     更多教学视频和资料下载,欢迎关注以下信息: 我的优酷空间: http://i.youku.com/acetaohai123   我的在线论坛: ...