【转】StreamingAssetsPath 各平台路径


#if UNITY_EDITOR
string filepath = Application.dataPath + "/StreamingAssets";

#elif UNITY_IPHONE
string filepath = Application.dataPath +"/Raw";

#elif UNITY_ANDROID
string filepath =Application.streamingAssetsPath;

#endif


安卓获取文件时 需要通过WWW进行下载。其他平台通过IO 读取就行。

另外一种方法使用

Application.persistentDataPath 路径

不同的是Application.streamingAssetsPath 可以在项目中新建"StreamingAssets" 文件夹后预存自己 需要访问的文件。。

Android jar:file:// + Application.dataPath + "/StreamingAssets";

IOS :file:// + Application.dataPath +"/Raw";


public static string initAssetPath() {
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
        return "file://" + Application.dataPath + "/StreamingAssets/";
#elif UNITY_ANDROID
        return "jar:file://" + Application.dataPath + "!/assets/";
#elif UNITY_IPHONE
        return Application.dataPath + "/Raw/";
#else
        return "";
#endif
    }


"StreamingAssets" 文件夹  
读取下载创建都使用:

string  m_filepath = Application.persistentDataPath;

"StreamingAssets" 文件夹  
读取下载都使用:
string  m_filepath ="jar:file://" + Application.persistentDataPath;
参考连接:http://docs.unity3d.com/ScriptReference/Application-streamingAssetsPath.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值