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 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)
网络播放器:到播放器数据文件夹的绝对路径(没有实际的数据文件名称)

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

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public void Awake() {
		print(Application.dataPath);
	}
}
// print the path to the data folder
// 打印到数据文件夹的路径

print (Application.dataPath);
Page last updated: 2010-12-14