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 ...
随机推荐
- How do I find what queries were executing in a SQL memory dump?-----stack
https://blogs.msdn.microsoft.com/askjay/2010/10/03/how-do-i-find-what-queries-were-executing-in-a-s ...
- ARM体系下的GCC内联汇编
转:http://andyhuzhill.github.io/arm/gcc/asm/2012/09/25/gcc-inline-assemly/ 在操作系统级的编程中,有时候,C语言并不能完全的使用 ...
- 查看mysql服务器连接
查看服务器连接,排查连接过多,查看连接状态时特别有用! 命令: show full processlist 作用: 显示当前运行的线程以及状态,也可以根据该命令来查看服务器状态. Id: 连接Id.U ...
- FORM-加载前指定日期时间格式
PRE-FORM -- Standard date format --BEGIN set_application_property(DATE_FORMAT_COMPATIBILITY_MODE, ' ...
- Ubuntu下,清屏等终端常用命令
转自:http://blog.csdn.net/gaojinshan/article/details/9314435 # ctrl + l - 清屏 . cLear# ctrl + c - 终止命令. ...
- jquery的表单验证方法,一个function能不能同时捕捉点击事件和按键事件?能不能再优化下,有代码。
// 该jquery扩展引自 http://www.ghostsf.com/tools/389.html 方法名是作者博客的命名 $.fn.ghostsf_serialize = function ( ...
- 关于使用Android新版Camera即Camera2的使用介绍 暨解决Camera.PreviewCallback和MediaRecorder无法同时进行
新的相机API也就是Camera2是在Android 5.0引进的.通常情况下,我们都是使用Android旧的相机API,纵然在Android Studio里老是提示已经废弃,但是只要都能用,也就没必 ...
- 流畅的python第二十章属性描述符学习记录
描述符是对多个属性运用相同存取逻辑的一种方式.例如,Django ORM 和 SQL Alchemy等 ORM 中的字段类型是描述符,把数据库记录中字段里的数据与 Python 对象的属性对应起来.描 ...
- Unity3D新手教学,让你十二小时,从入门到掌握!(一) [转]
http://blog.csdn.net/aries_h/article/details/47307799 版权声明:本文为Aries原创文章,转载请标明出处.如有不足之处欢迎提出意见或建议,联系QQ ...
- DX12
CD3DX12_DESCRIPTOR_RANGE1 的baseShaderRegister 用来指定 t0 t1 b0 b1...的index t0 srv b0 constant buffer u0 ...