unity3d深入学习笔记2:项目数据路径
2016-02-17 15:08
399 查看
首先贴上一段项目中的代码:
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
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
相关文章推荐
- unity3d深入学习笔记1:获取系统信息
- unity3d基础学习笔记17:C# C++结构体
- unity3d基础学习笔记16:C#Socket应用
- unity3d基础学习笔记15:NGUi动态加载 prefabs
- unity3d基础学习笔记14:ngui
- unity3d基础学习笔记12:输入控制
- unity3d基础学习笔记11:socket函数
- unity3d基础学习笔记10:socket概述
- unity3d基础学习笔记9:3d动画控制
- unity3d基础学习笔记8:定时器
- unity3d基础学习笔记7:适应屏幕
- unity3d基础学习笔记5:常用函数
- unity3d基础学习笔记4:Hierarchy与场景搭建
- unity3d基础学习笔记3:坐标
- unity3d基础学习笔记2:脚本篇
- unity3d基础学习笔记1:监视面板与基本组件
- Unity bug 合集(1-50)
- Unity Shader 内置函数
- unity shader 固定管线实例(二) 光照 颜色和纹理
- unity shader 固定管线实例(一) 基础光照效果纯颜色