找回密码
 立即注册
查看: 6696|回复: 80

[脚本] Unity3d 在不同设备中的文件读写 的路径

[复制链接]
发表于 2013-5-20 10:19 | 显示全部楼层 |阅读模式
Application.dataPath : 数据路径

Unity Editor: <path tp project folder>/Assets
Unity 编辑器:<工程文件夹的路径>/Assets

Mac player: <path to player app bundle>/Contents
Mac播放器:<到播放器应用的路径>/Contents

iPhone player: <path to player app bundle>/<AppName.app>/Data
iPhone播放器:<到播放器应用的路径>/<AppName.app>/Data

Win player: <path to executablename_Data folder>
Win播放器:< 包含可执行播发器的文件夹的路径>\Data

Dashboard widget: <path to the dashboard widget bundle>
Dasboard窗口:< dashboard widget bundle的路径>

Web player: The absolute url to the player data file folder (without the actual data file name)
网络播放器:到播放器数据文件夹的绝对路径(没有实际的数据文件名称)


在IOS真机设备中 需要在<path to player app bundle>/Documents路径下才可以读写。

unity3d中通过如下操作获取Document文件路径

    public string Path
    {
        get{
            string    path=null;
            if(Application.platform==RuntimePlatform.IPhonePlayer)
            {
                path= Application.dataPath.Substring (0, Application.dataPath.Length - 5);
                path = path.Substring(0, path.LastIndexOf('/'))+"/Documents/";   
            }
            else
            {
                path=Application.dataPath+"/Resource/GameData/";
            }
            return path;
        }     
    }
发表于 2017-3-2 16:54 | 显示全部楼层
很不错
发表于 2017-3-2 16:19 | 显示全部楼层
好帖就是要顶
发表于 2017-3-2 16:28 | 显示全部楼层
说的非常好
发表于 2017-3-2 16:12 | 显示全部楼层
很好哦
发表于 2017-3-2 16:19 | 显示全部楼层
LZ真是人才
发表于 2017-3-17 07:50 | 显示全部楼层
很不错
发表于 2017-3-17 07:44 | 显示全部楼层
好帖就是要顶
发表于 2017-3-17 07:36 | 显示全部楼层
顶顶多好
发表于 2017-3-17 07:32 | 显示全部楼层
真心顶
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-5 16:15 , Processed in 0.099322 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表