/// <summary>
/// 获得不同平台下文件的路径
/// </summary>
public class GetFilePath
{
/// <summary>
/// 获得当前文件保存的路径
/// </summary>
/// <returns></returns>
public static string getPath()
{
string src =
#if UNITY_EDITOR
Application.persistentDataPath;
#elif UNITY_ANDROID
Application.persistentDataPath;
#else
Application.persistentDataPath;
#endif
return src;
}
public static string FilePath = "";//文件的路径
/// <summary>
/// 获得不同平台文件的保存位置
/// </summary>
/// <returns></returns>
public static string GetPath()
{
if (Application.isMobilePlatform)
{
if (Application.platform == RuntimePlatform.Android)
{
//安卓平台
FilePath = "jar:file://" + Application.dataPath + "!/assets/";
return FilePath;
}
else if (Application.platform == RuntimePlatform.IPhonePlayer)
{
//IOS平台
FilePath = Application.dataPath + "/Raw";
return FilePath;
}
else
{
return FilePath;
}
}
else
{
//PC平台
FilePath = Application.dataPath + "/StreamingAssets";
return FilePath;
}
}
}