unity, read text file
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的更多相关文章
- shell脚本执行时报"bad interpreter: Text file busy"的解决方法
在执行一个shell脚本时,遇到了“-bash: ./killSession.sh: /bin/bash: bad interpreter: Text file busy”错误提示,如下所示: [or ...
- 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 ...
- eclipse的使用-------Text File Encoding没有GBK选项的设置
eclipse的使用-------Text File Encoding没有GBK选项的设置 2013-12-25 09:48:06 标签:java myeclipse使用 有一个项目是使用GBK编码的 ...
- 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 ...
- create feature from text file
'''---------------------------------------------------------------------------------- Tool Name: Cre ...
- 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 ...
- 【转】shell脚本执行时报"bad interpreter: Text file busy"的解决方法
1)问题现象: 在ubuntu下执行以下脚本( while_count),报错: -bash: ./while_count: /bin/bash: bad interpreter: Text file ...
- New text file line delimiter
Window -> Preferences -> General -> Workspace : Text file encoding :Default : 选择此项将设定文件为系统默 ...
- [转]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 ...
随机推荐
- (Mark)JS中的上下文
执行上下文的代码被分成两个基本的阶段来处理: 进入执行上下文 执行代码 变量对象的修改变化与这两个阶段紧密相关. 注:这2个阶段的处理是一般行为,和上下文的类型无关(也就是说,在全局上下文和函数上下文 ...
- [标准性文档]WEB应用安全验证标准
这是根据OWASP ASVS翻译过来的,可作为WEB应用开发的验收标准(未包含具体细节),值得注意的是,验收标准并非越严格越好,应根据企业自身的业务需求判定. WEB应用安全验证标准 安全验证等级的定 ...
- HDU 4633 Who's Aunt Zhang (2013多校4 1002 polya计数)
Who's Aunt Zhang Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Vue 小项目的最佳实践
项目简介 目前一期只是为App内某个模块资讯模块文章的分享和APP下载,后续还会有更多的功能,为了项目可扩展.可伸缩结合了我以前的实践搭建了此项目项目地址,如果这个简单的项目能给您带来帮助请给小哥哥⭐ ...
- 从connect到express02-中间件morgan
控制台输出请求日志 输出格式 默认格式: dev, combined, tiny等 自定义格式: morgan(':method :url :status :res[content-length] - ...
- 你可能从未听过的 Linux 发行版
Hanthana Linux 官方主页:http://www.hanthana.org Hanthana Linux 基于 Fedora,主要面向 IT 教育,默认包含额外的编/解码器及多媒体播放器. ...
- [Todo]非常好的免费IT书籍资源 & Github排名
今天看github排名,看到排在第二位的是免费书籍: https://github.com/vhf/free-programming-books/blob/master/free-programmin ...
- http网络通信--页面源代码查看
1.要在andorid中实现网络图片查看,涉及到用户隐私问题,所以要在AndroidManifest.xml中添加访问网络权限 <uses-permission android:name=&qu ...
- Maven中的SNAPSHOT版本和正式版本理解
Maven中建立的依赖管理方式基本已成为Java语言依赖管理的事实标准,Maven的替代者Gradle也基本沿用了Maven的依赖管理机制.在Maven依赖管理中,唯一标识一个依赖项是由该依赖项的三个 ...
- linux内核及其模块的查询,加载,卸载 lsusb等
http://blog.sina.com.cn/s/blog_53e81e2a0100zkxi.html 1,/sbin/update-modules文件,他是一个linux通用的模块管理脚本程序. ...