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 ...
随机推荐
- 基于tiny4412的Linux内核移植 -- PWM子系统学习(七)
作者信息 作者: 彭东林 邮箱:pengdonglin137@163.com QQ:405728433 平台简介 开发板:tiny4412ADK + S700 + 4GB Flash 要移植的内核版本 ...
- 《Windows驱动开发技术详解》之StartIO例程
内容中包含 base64string 图片造成字符过多,拒绝显示
- nginx安装和配置
一.安装:yum install nginx service nginx restart/start/check/status/... 二.配置:官网文档 http://nginx.org/en/do ...
- iOS:创建单例对象的两种方式
单例模式:创建单例对象的两种方式 方式一:iOS4版本之前 static SingleClassManager *singleManager = nil; +(SingleClas ...
- delphi Align属性
---------------------------------------------- -
- SQL盲注测试高级技巧
写在前面: 这篇文章主要写了一些加快盲注速度的技巧和盲注中比较精巧的语句,虽然注入并不是什么新技术了.但是数据库注入漏洞依然困扰着每一个安全厂商,也鞭策着每一个安全从业者不断前进. 正文: 首先来简单 ...
- Qunit的使用
1.新建一个html页面,如下 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "ht ...
- 《大规模web服务开发技术》笔记
前段时间趁空把<大规模web服务开发技术>这本书看完了,今天用一下午时间重新翻了一遍,把其中的要点记了下来,权当复习和备忘.由于自己对数据压缩.全文检索等还算比较熟,所以笔记内容主要涉及前 ...
- hdu-Coins
http://acm.hdu.edu.cn/showproblem.php?pid=2844 Problem Description Whuacmers use coins.They have coi ...
- HTTP状态码及说明