Application.streamingAssetsPath
【Application.streamingAssetsPath】
This API contains the path to the StreamingAssets folder (Read Only).
If you have a "StreamingAssets" folder in the Assets folder of your project, it will be copied to your player builds and be present in the path given by Application.streamingAssetsPath.
Note that on some platforms it is not possible to directly access the StreamingAssets folder because there is no file system access in the web platforms, and because it is compressed into the .apk file on Android. On those platforms, a url will be returned, which can be used using the WWW class.
using UnityEngine;
using System.Collections; public class ExampleClass : MonoBehaviour {
public string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "MyFile");
public string result = "";
IEnumerator Example() {
if (filePath.Contains("://")) {
WWW www = new WWW(filePath);
yield return www;
result = www.text;
} else
result = System.IO.File.ReadAllText(filePath);
}
}
【Details】
It is sometimes useful to place files into the normal filesystem on the target machine to make them accessible via a pathname. An example of this is the deployment of a movie file on iOS devices; the original movie file must be available from a location in the filesystem to be played by the PlayMovie function.

Note that on Android, the files are contained within a compressed .jar file (which is essentially the same format as standard zip-compressed files). This means that if you do not use Unity’s WWW class to retrieve the file then you will need to use additional software to see inside the .jar archive and obtain the file.
It’s always best to use Application.streamingAssetsPath to get the location of the StreamingAssets folder, it will always point to the correct location on the platform where the application is running.
Application.streamingAssetsPath的更多相关文章
- Application中的路径
前提条件 项目工程目录:E:/Work/cosmosbox/cb-client/ 我电脑当前的用户名:qingqing PersistentDataPath Application.persisten ...
- Unity3D各平台Application.xxxPath的路径
前几天我们游戏在一个同事的Android手机上启动时无法正常进入,经查发现Application.temporaryCachePath和Application.persistentDataPath返回 ...
- (转)Unity3D研究院之手游开发中所有特殊的文件夹(assetbundle与Application.persistentDataPath)
这里列举出手游开发中用到了所有特殊文件夹. 1.Editor Editor文件夹可以在根目录下,也可以在子目录里,只要名子叫Editor就可以.比如目录:/xxx/xxx/Editor 和 /Edi ...
- 安卓 通过www读取Application.persistentDataPath
今天在读取Application.persistentDataPath路径下的图片时,在前面加上“file:///” 例如 #if UNITY_EDITOR || UNITY_STANDALONE r ...
- Unity3D 5.3 新版AssetBundle使用方案及策略
1.概览 Unity3D 5.0版本之后的AssetBundle机制和之前的4.x版本已经发生了很大的变化,一些曾经常用的流程已经不再使用,甚至一些老的API已经被新的API所取代. 因此,本文的主要 ...
- Unity AssetBundle爬坑手记
这篇文章从AssetBundle的打包,使用,管理以及内存占用各个方面进行了比较全面的分析,对AssetBundle使用过程中的一些坑进行填补指引以及喷! AssetBundle是Unity推荐的 ...
- Unity3D移动平台动态读取外部文件全解析
前言: 一直有个想法,就是把工作中遇到的坑通过自己的深挖,总结成一套相同问题的解决方案供各位同行拍砖探讨.眼瞅着2015年第一个工作日就要来到了,小匹夫也休息的差不多了,寻思着也该写点东西活动活动大脑 ...
- Unity 文件读取
存储: 在程序发布后文件的存放有两种,第一种是打包到Uniyt的资源包中(*.unity3D),第二种就是把文件存放在一个特殊的目录如:StreamingAssets,这个目录的东西Unity不会打包 ...
- GJM : Unity调用系统窗口选择本地文件
感谢您的阅读.喜欢的.有用的就请大哥大嫂们高抬贵手"推荐一下"吧!你的精神支持是博主强大的写作动力以及转载收藏动力.欢迎转载! 版权声明:本文原创发表于 [请点击连接前往] ,未经 ...
随机推荐
- 解决Eclipse中文乱码的问题
注意:显示中文所有的编码方式主要是GBK和UTF-8,UTF-8是国际通用的中文编码标准,推荐使用. 一. 设置工作空间的编码 编辑器的编码会影响到所有的项目中的字符的显示,可以说是作用最为广泛的设置 ...
- flv格式的播放代码
<object classid="clsid:D27CDB6E-AE6D-444553540000" class="player2" codebase=& ...
- nginx中使用 md5
core/ngx_md5.h 头文件 /* * Copyright (C) Igor Sysoev * Copyright (C) Nginx, Inc. */ #ifndef _NGX_MD5_H_ ...
- 树莓派(raspberry pi)系统开发
[树莓派(raspberry pi)] 01.在linux环境下给树莓派安装系统及入门各种资料 [树莓派(raspberry pi)] 02.PI3安装openCV开发环境做图像识别(详细版) 出处: ...
- {转载}需要同时设置 noatime 和 nodiratime 吗?
相信对性能.优化这些关键字有兴趣的朋友都知道在 Linux 下面挂载文件系统的时候设置 noatime 可以显著提高文件系统的性能.默认情况下,Linux ext2/ext3 文件系统在文件被访问.创 ...
- C++ Primer第五版答案
Downloads Download the source files for GCC 4.7.0. Download the source code files for MS Visual Stud ...
- python 书籍推荐 一
最近"瑞丽模特学Python"的热点牵动了大江南北程序员的心,有人说这是炒作,也有人说这是推广Python的爆点...我嘿嘿一笑,美女就是美女,眼光那是杠杠的,不仅人美,学的语言也 ...
- Vue 基本用法
Vue的基本用法 模板语法{{ }} 关闭掉 django中提供的模板语法{{ }} 指令系统 v-text v-html v-show和v-if v-bind和v-on v-for v-model ...
- Java 经典练习题_Day010
final 变量能被显式地初始化并且只能初始化一次.被声明为 final 的对象的引用不能指向不同的对象.但是 final 对象里的数据可以被改变.也就是说 final 对象的引用不能改变,但是里面的 ...
- MySQL 高性能存储引擎:TokuDB初探
在安装MariaDB的时候了解到代替InnoDB的TokuDB,看简介非常的棒,这里对ToduDB做一个初步的整理,使用后再做更多的分享. 什么是TokuDB? 在MySQL最流行的支持全事务的引擎为 ...