Unity3D中各种Path
2016-05-26 19:45
519 查看
Unity中Path在不同平台下值
IOS:
Application.dataPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data
Application.streamingAssetsPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data/Raw
Application.persistentDataPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Documents
Application.temporaryCachePath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Library/Caches
Android:
Application.dataPath : /data/app/xxx.xxx.xxx.apk
Application.streamingAssetsPath : jar:file:///data/app/xxx.xxx.xxx.apk/!/assets
Application.persistentDataPath : /data/data/xxx.xxx.xxx/files
Application.temporaryCachePath : /data/data/xxx.xxx.xxx/cache
Windows Web Player:
Application.dataPath : file:///D:/MyGame/WebPlayer (即导包后保存的文件夹,html文件所在文件夹)
Application.streamingAssetsPath :
Application.persistentDataPath :
Application.temporaryCachePath :
****************************************************************************************************************
路径拼装方法:
public class PathUtils
{
private static PathUtils _instance = null;
public static PathUtils Instance()
{
if (_instance == null)
{
_instance = new PathUtils();
}
return _instance;
}
//private static string ApplicationDataPath = "";
private static string ApplicationStreamingPath = "";
private static string ApplicationPersistentDataPath = "";
private static string ApplicationTemporaryDataPath = "";
private static bool m_bIsEditor = false;
public enum UnityPathType
{
UnityPath_Resources = 0, // Unity内置路径,只支持Resource.Load方法读取
UnityPath_StreamAsset, // Unity流目录,只读目录
UnityPath_PersistentData, // Untity持久目录, 支持读写 文本文件或者二进制文件可以存放
UnityPath_TemporaryCache, // Unity临时缓存目录 功能同 UnityPath_PersistentData
}
public PathUtils()
{
//ApplicationDataPath = Application.dataPath + "/";
if (Application.platform == RuntimePlatform.Android) /// Application.streamingAssetsPath在安卓平台下已经自带了 jar:file:///
{
ApplicationStreamingPath = Application.dataPath + "!/assets/";
}
else
{
ApplicationStreamingPath = Application.streamingAssetsPath + "/";
}
ApplicationPersistentDataPath = Application.persistentDataPath + "/";
ApplicationTemporaryDataPath = Application.temporaryCachePath + "/";
}
/// <summary>
/// 获取文件钱路径 支持文件系统 UnityPath_StreamAesset目录在安卓平台只支持www的方式来读取
/// </summary>
/// <param name="strFileName"></param>
/// <returns></returns>
public string FullPathFileName(ref string strFileName, UnityPathType pathType = UnityPathType.UnityPath_PersistentData)
{
string strFullPath = "";
switch (pathType)
{
case UnityPathType.UnityPath_StreamAsset:
strFullPath = ApplicationStreamingPath + strFileName;
break;
case UnityPathType.UnityPath_PersistentData:
strFullPath = ApplicationPersistentDataPath + strFileName;
break;
case UnityPathType.UnityPath_TemporaryCache:
strFullPath = ApplicationTemporaryDataPath + strFileName;
break;
case UnityPathType.UnityPath_CustomPath:
strFullPath = ResourcePath + strFileName;
break;
}
return strFullPath;
}
/// <summary>
/// 获取文件URL路径 URL格式的路径则必须使用www来读取
/// </summary>
/// <param name="strFileName"></param>
/// <returns></returns>
public string FullUrlFileName(ref string strFileName, UnityPathType pathType = UnityPathType.UnityPath_StreamAsset)
{
string strFullUrl = "";
switch (pathType)
{
case UnityPathType.UnityPath_StreamAsset:
strFullUrl =
acc8
ApplicationStreamingPath + strFileName;
break;
case UnityPathType.UnityPath_PersistentData:
strFullUrl = ApplicationPersistentDataPath + strFileName;
break;
case UnityPathType.UnityPath_TemporaryCache:
strFullUrl = ApplicationTemporaryDataPath + strFileName;
break;
case UnityPathType.UnityPath_CustomPath:
strFullUrl = ResourcePath + strFileName;
break;
}
switch (Application.platform)
{
case RuntimePlatform.Android:
if (pathType == UnityPathType.UnityPath_StreamAsset)
{
strFullUrl = "jar:file://" + strFullUrl;
}
else
{
strFullUrl = "file://" + strFullUrl;
}
break;
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.WindowsPlayer:
case RuntimePlatform.WindowsEditor:
case RuntimePlatform.OSXEditor:
{
strFullUrl = "file://" + strFullUrl;
}
break;
}
return strFullUrl;
}
}
IOS:
Application.dataPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data
Application.streamingAssetsPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data/Raw
Application.persistentDataPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Documents
Application.temporaryCachePath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Library/Caches
Android:
Application.dataPath : /data/app/xxx.xxx.xxx.apk
Application.streamingAssetsPath : jar:file:///data/app/xxx.xxx.xxx.apk/!/assets
Application.persistentDataPath : /data/data/xxx.xxx.xxx/files
Application.temporaryCachePath : /data/data/xxx.xxx.xxx/cache
Windows Web Player:
Application.dataPath : file:///D:/MyGame/WebPlayer (即导包后保存的文件夹,html文件所在文件夹)
Application.streamingAssetsPath :
Application.persistentDataPath :
Application.temporaryCachePath :
****************************************************************************************************************
路径拼装方法:
public class PathUtils
{
private static PathUtils _instance = null;
public static PathUtils Instance()
{
if (_instance == null)
{
_instance = new PathUtils();
}
return _instance;
}
//private static string ApplicationDataPath = "";
private static string ApplicationStreamingPath = "";
private static string ApplicationPersistentDataPath = "";
private static string ApplicationTemporaryDataPath = "";
private static bool m_bIsEditor = false;
public enum UnityPathType
{
UnityPath_Resources = 0, // Unity内置路径,只支持Resource.Load方法读取
UnityPath_StreamAsset, // Unity流目录,只读目录
UnityPath_PersistentData, // Untity持久目录, 支持读写 文本文件或者二进制文件可以存放
UnityPath_TemporaryCache, // Unity临时缓存目录 功能同 UnityPath_PersistentData
}
public PathUtils()
{
//ApplicationDataPath = Application.dataPath + "/";
if (Application.platform == RuntimePlatform.Android) /// Application.streamingAssetsPath在安卓平台下已经自带了 jar:file:///
{
ApplicationStreamingPath = Application.dataPath + "!/assets/";
}
else
{
ApplicationStreamingPath = Application.streamingAssetsPath + "/";
}
ApplicationPersistentDataPath = Application.persistentDataPath + "/";
ApplicationTemporaryDataPath = Application.temporaryCachePath + "/";
}
/// <summary>
/// 获取文件钱路径 支持文件系统 UnityPath_StreamAesset目录在安卓平台只支持www的方式来读取
/// </summary>
/// <param name="strFileName"></param>
/// <returns></returns>
public string FullPathFileName(ref string strFileName, UnityPathType pathType = UnityPathType.UnityPath_PersistentData)
{
string strFullPath = "";
switch (pathType)
{
case UnityPathType.UnityPath_StreamAsset:
strFullPath = ApplicationStreamingPath + strFileName;
break;
case UnityPathType.UnityPath_PersistentData:
strFullPath = ApplicationPersistentDataPath + strFileName;
break;
case UnityPathType.UnityPath_TemporaryCache:
strFullPath = ApplicationTemporaryDataPath + strFileName;
break;
case UnityPathType.UnityPath_CustomPath:
strFullPath = ResourcePath + strFileName;
break;
}
return strFullPath;
}
/// <summary>
/// 获取文件URL路径 URL格式的路径则必须使用www来读取
/// </summary>
/// <param name="strFileName"></param>
/// <returns></returns>
public string FullUrlFileName(ref string strFileName, UnityPathType pathType = UnityPathType.UnityPath_StreamAsset)
{
string strFullUrl = "";
switch (pathType)
{
case UnityPathType.UnityPath_StreamAsset:
strFullUrl =
acc8
ApplicationStreamingPath + strFileName;
break;
case UnityPathType.UnityPath_PersistentData:
strFullUrl = ApplicationPersistentDataPath + strFileName;
break;
case UnityPathType.UnityPath_TemporaryCache:
strFullUrl = ApplicationTemporaryDataPath + strFileName;
break;
case UnityPathType.UnityPath_CustomPath:
strFullUrl = ResourcePath + strFileName;
break;
}
switch (Application.platform)
{
case RuntimePlatform.Android:
if (pathType == UnityPathType.UnityPath_StreamAsset)
{
strFullUrl = "jar:file://" + strFullUrl;
}
else
{
strFullUrl = "file://" + strFullUrl;
}
break;
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.WindowsPlayer:
case RuntimePlatform.WindowsEditor:
case RuntimePlatform.OSXEditor:
{
strFullUrl = "file://" + strFullUrl;
}
break;
}
return strFullUrl;
}
}
相关文章推荐
- Unity3d Input按键系统
- unity3d之在屏幕上画线
- 在Unity里内嵌SVN基本操作
- 在Unity5中使用C#脚本实现UI的下滑、变色、渐隐渐现效果
- unity文件夹
- unity3d常用的游戏对象引用技巧
- Unity3D中的线性插值Lerp()函数解析
- UNITY3D自学(五)-- 导航寻路的学习
- unity中如何解决两个物体的绑定
- Unity 2D射线与 3D射线 UI射线
- Unity5.x的GUIText被UI Text所取代--增加头文件UnityEngine.UI
- Unity3D客户端和Java服务端使用Protobuf
- unity ugui自适应
- unity 优化 WaitForTargetFPS Gfx.WaitForPresent Graphics.PresentAndSync
- Unity3D 物体移动方式总结
- unity3d 各种路径&权限
- Unity实用案例之——CameraController
- Unity3D实现3D立体游戏原理及过程
- unity3D 涂涂乐使用shader实现上色效果
- unity3D AR涂涂乐制作浅谈