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 ...
随机推荐
- llvm之旅第一站 - 编译及简单使用 LLVM 图解
http://www.nagain.com/activity/article/4/ http://blog.csdn.net/snsn1984/article/details/8593380
- 18 个最佳代码编辑器/IDE推荐
本文为开发人员收录了18个最好的代码编辑器/IDE工具,希望你会喜欢. 1) chocolatapp Chocolat是最新出现的一款强大的Mac系统文本编辑器,兼具原生的Cocoa及强大的文本编辑功 ...
- NPD南京炮苑电子技术研究所----NPD治疗仪
NPD南京炮苑电子技术研究所有限公司: http://www.npd365.com/ 研发药物离子导入和中医定向透药技术. 南京炮苑玉古康2号NPD系列专用中医定向透药治疗仪腰颈椎疼痛贴 N ...
- propertychange方法
1.html文件 <td> <input id="clientPhone" type="text" name="clientPhon ...
- Android检测网络连接
Android检测网络连接 import android.app.AlertDialog; import android.content.Context; import android.content ...
- 用WM_COPYDATA消息来实现两个进程之间传递数据
文着重讲述了如果用WM_COPYDATA消息来实现两个进程之间传递数据. 进程之间通讯的几种方法:在Windows程序中,各个进程之间常常需要交换数据,进行数据通讯.常用的方法有 1.使用内存映射 ...
- [Todo]Redis & Mysql可以看的书籍
Redis实战(我下的版本是网络版,还有一版是黄健宏翻译的版本,正在找) 高性能Mysql第三版 都在目录: /Users/baidu/Documents/Data/Interview/存储-Nosq ...
- http://www.linuxidc.com/Linux/2016-04/129738.htm
http://www.linuxidc.com/Linux/2016-04/129738.htm
- ORA-04030
ORA-04030: 在尝试分配...字节(...)时进程内存不足的原因分析及解决办法 正在使用的oracle 11g数据库,前天在用一段时间后(开始要较长时间才出现,后来较短时间就出现),频繁报OR ...
- phpcms的后台网站直接访问正常,百度快照收录链接访问跳转到非法网站
问题: phpcms制作的网站直接访问正常,百度快照收录链接访问跳转到非法网站 百度快照收录网站域名,访问时自动跳转到一个非法网站 检查静态页index.html,index.php 网页内引用 ...