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 ...
随机推荐
- Run-Time Check Failure #0
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is ...
- emailautocomplete
CSS代码: .emailist{border:1px solid #bdbdbd; border-radius: 4px; background-color:#fff; color:#666; fo ...
- 【UEditor】关于导入ueditor-1.1.3.jar的问题---
最近做一个项目,使用了百度的富文本框,本来是很简便易用的东西,在回显给富文本框的时候, var ue = UE.getEditor('container'); var noticeContent = ...
- phpok -- 域名问题
nginx会改变连接的baseurl, 所以要改变nginx的server name的配置. 将网站改为静态也需配置nginx.
- 获取dataset结果集的第一行第一列字段
DataSet fileNameDs = DbHelper.excuteSqlResultDataSet(strSql); ) { DataTable fileNameDt = fileNameDs. ...
- JAVA常见算法题(二十九)
package com.forezp.util; import java.util.Scanner; /** * 判断输入的5个字符串的最大长度,并输出 * * * @author Administr ...
- django admin后台接入tinymce并且支持图片上传
首先:下载tinymce 地址是https://www.tinymce.com/ 点击download 下载社区版本即可 接着:把压缩包内tinymce目录内的所有文件和文件夹复制到Django项目中 ...
- 阻止jQuery事件冒泡
Query对DOM的事件触发具有冒泡特性.有时利用这一特性可以减少重复代码,但有时候我们又不希望事件冒泡.这个时候就要阻止 jQuery.Event冒泡. 在jQuery.Event 的文档 中的开头 ...
- http://www.cnblogs.com/ITtangtang/archive/2012/05/21/2511749.html
http://www.cnblogs.com/ITtangtang/archive/2012/05/21/2511749.html http://blog.sina.com.cn/s/blog_538 ...
- 如何使用 awk 的 ‘next’ 命令
导读 在 awk 系列文章中,我们来看一下next 命令 ,它告诉 awk 跳过你所提供的所有剩下的模式和表达式,直接处理下一个输入行.next 命令帮助你阻止运行命令执行过程中多余的步骤. 要明白它 ...