查看: 1666|回复: 1
打印 上一主题 下一主题

求助,读取2进制资源文件的android设备的路径设置问题?

[复制链接]

2508

主题

2

听众

3万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
32806
精华
12

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2013-5-30 08:51:30 |只看该作者 |倒序浏览
用的c#写的脚本。项目中需要把2进制资源文件读出来给FileStream 变量。然后解析这个FileStream 变量。







目前用的方法是:





FileStream stFile = null;

string path = Application.dataPath + "/Resources/test.dat";

stFile = new FileStream(path, FileMode.Open, FileAccess.Read);





连接android设备编译,找不到文件test.dat文件。经测试是path的路径设置问题。





从网上找解决办法。









目前试过如下的代码:









方法01:

string path = Application.dataPath + "/Raw/test.dat"

stFile = new FileStream(path, FileMode.Open, FileAccess.Read);





方法02:

string path= Application.persistentDataPath + "/test.dat" ;

stFile = new FileStream(path, FileMode.Open, FileAccess.Read);





方法03:

资源文件放到\Assets\StreamingAssets目录下

string path = "jar:file://" + Application.dataPath + "!/assets/test.dat"

WWW www = new WWW(path);

stFile = new FileStream(www.url, FileMode.Open, FileAccess.Read);





方法04:

TextAsset t = (TextAsset)Resources.Load("text", typeof(TextAsset));

stFile = new FileStream(t.ToString, FileMode.Open, FileAccess.Read);









目前都有问题,android还未运行通过。以下是我找的一些资料网址。









http://forum.unity3d.com/threads/102451-WWW-file-protocol-error

http://forum.unity3d.com/threads/84478-How-can-i-load-assetsbundle-from-android-local-device

http://forum.unity3d.com/threads/65344-Assert-bundles-in-the-data-folder?p=466159&viewfull=1#post466159

http://answers.unity3d.com/questions/184651/how-to-load-text-file.html

http://answers.unity3d.com/questions/126578/how-do-i-get-into-my-streamingassets-folder-from-t.html

http://forum.unity3d.com/threads/61198-Data-Storage-How-to-read-write-files

http://www.mindthecube.com/blog/2009/11/reading-text-data-into-a-unity-game

http://www.previewlabs.com/file-io-in-unity3d/

http://www.google.com.hk/webhp?hl=zh-CN&sourceid=cnhp#hl=zh-CN&safe=strict&gbv=2&q=unity+android+load+txt+file+&oq=unity+android+load+txt+file+&aq=f&aqi=&aql=&gs_**=e&gs_upl=1632819l1673813l17l1673956l32l29l2l14l16l0l221l1453l6.5.1l12l0&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=32485b744981b8ba&biw=1280&bih=710









哪位有实际经验的可否给点解决办法。十分感谢。
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

nts    

3

主题

1

听众

743

积分

初级设计师

Rank: 3Rank: 3

纳金币
7
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

沙发
发表于 2013-10-22 09:08:46 |只看该作者
nice work thx
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

关闭

站长推荐上一条 /1 下一条

手机版|纳金网 ( 闽ICP备08008928号

GMT+8, 2024-5-6 17:26 , Processed in 0.083586 second(s), 32 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部