unity3d深入学习笔记2:项目数据路径

首先贴上一段项目中的代码:

privatestatic readonly string pathURL =

#ifUNITY_ANROID

        "jar:file://" +Application.dataPath + "!/assets/";

#elifUNITY_IPHONE

        Application.dataPath +"/Raw/";

#elifUNITY_STANDALONE_WIN || UNITY_EDITOR

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

#else

        string.Empty;

#endif

就是当设备不同的时候,项目的数据路径也设置不同的值,是一个只读的字符串类型。添加一个get接口就可以轻松得到这个路径

        

下面是unity圣典的介绍:

Application.dataPath 数据路径

static var dataPath : string

Description描述

Contains the path to the game data folder (Read Only).

包含游戏数据文件夹的路径(只读)。

The value depends on which platform you are running on:

这个值依赖于运行的平台:

Unity Editor: <path tp project folder>/Assets
Unity
编辑器:<工程文件夹的路径>/Assets
Mac player: <path to player app bundle>/Contents
Mac
播放器:<到播放器应用的路径>/Contents
iPhone player: <path to player appbundle>/<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 theactual data file name)
网络播放器:到播放器数据文件夹的绝对路径(没有实际的数据文件名称)

Note that the string returned on a PC will use a forwardslash as a folder separator.
值得注意的是如果在PC上使用时需要在每个文件夹前加入斜杠

using UnityEngine;

using System.Collections;

 

public class example : MonoBehaviour {

publicvoid Awake() {

   print(Application.dataPath);

}

}

// print the pathto the data folder

// 打印到数据文件夹的路径

 

print (Application.dataPath);

 

引用来自unity圣典:http://game.ceeger.com/Script/Application/Application.dataPath.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

左右...

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值